Следующая проблема возникла с gem mysql2.
При запуске команды rake db:create система возвращала ошибку:
|
1 2 3 4 5 6 7 |
C:\Documents and Settings\user\ruby\app>rake db:create rake aborted! cannot load such file -- mysql2/2.0/mysql2 C:/Documents and Settings/user/ruby/app/config/application.rb:7:in `<top (required)>' C:/Documents and Settings/user/ruby/app/Rakefile:5:in `<top (required)>' (See full trace by running task with --trace) |
А при попытке создать модель, другую:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
C:\Documents and Settings\user\ruby\app>rails generate model User name:st ring hashed_password:string salt:string C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2. rb:2:in `require': cannot load such file -- mysql2/2.0/mysql2 (LoadError) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/m ysql2/mysql2.rb:2:in `<top (required)>' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/m ysql2.rb:9:in `require' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/m ysql2.rb:9:in `<top (required)>' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti me.rb:72:in `require' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runti me.rb:72:in `block (2 levels) in require' |
Решение проблемы:
- Скачать файл отсюда
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
Эту ссылку (или похожую) вы получите, если попробуете запустить команду
12345678910111213141516C:\Documents and Settings\user\ruby\app>gem install mysql2============================================================================You've installed the binary version of mysql2.It was built using MySQL Connector/C version 6.0.2.It's recommended to use the exact same version to avoid potential issues.At the time of building this gem, the necessary DLL files where availablein the following download:http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pickAnd put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\bin - Полученный архив распаковать в корневой каталог ruby:
1C:\Ruby200\mysql-connector-c-noinstall-6.0.2-win32
Внутри каталога получится примерно такая структура:
1234567891011121314C:\Ruby200\mysql-connector-c-noinstall-6.0.2-win32>dirСодержимое папки C:\Ruby200\mysql-connector-c-noinstall-6.0.2-win3215.05.2013 19:21 <DIR> .15.05.2013 19:21 <DIR> ..15.05.2013 19:21 <DIR> bin07.08.2009 19:31 19 071 COPYING07.08.2009 19:31 5 139 EXCEPTIONS-CLIENT15.05.2013 19:21 <DIR> include15.05.2013 19:21 <DIR> lib07.08.2009 19:31 1 178 README3 файлов 25 388 байт5 папок 112 954 019 840 байт свободно - Выполнить команду для удаления некорректно установленной версии mysql2
12C:\Documents and Settings\user\ruby\app>gem uninstall mysql2Successfully uninstalled mysql2-0.3.11-x86-mingw32 - Установить gem mysql2 заново, указав в параметрах пути к скачанным библиотекам
1234gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\Ruby200\mysql-connector-c-noinstall-6.0.2-win32\lib"--with-mysql-include="C:\Ruby200\mysql-connector-c-noinstall-6.0.2-win32\include"--with-mysql-dir="C:\Ruby200\mysql-connector-c-noinstall-6.0.2-win32"'
Заметка: узнать версию Ruby On Rails можно с помощью команды rails -v.
Узнать версию Ruby: ruby -v .