2014-08-28 55 views
0

我使用Homebrew安装MySQL(brew install mysql),然后运行$ gem install mysql2。我在运行OSX 10.9.4的Mac上。不能耙:数据库迁移 - 继续获取'耙子中止!加载错误'

我改变目录到我的应用程序的根目录,然后尝试运行rake db:migrate命令,得到这个错误:

Levine_iMac$ rake db:migrate 
rake aborted! 
LoadError: dlopen(/Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method 
    Referenced from: /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle 
    Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib 
in /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle 
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in require' 
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in <top (required)>' 
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in <top (required)>' 
(See full trace by running task with --trace) 
Levine_iMac$ 

我尝试添加点东西给我的.bash_profile,如描述here,但那没用。

我尝试了一个sudo命令,如here所述,但这并不奏效。

然后我试图从2.1.1更新我的Ruby版本.. 2.1.2 ..,当我运行rake现在我收到此错误:DB上迁移

Levine_iMac$ rake db:migrate rake aborted! cannot load such file -- bundler/setup /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:1:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in '<top (required)>' (See full trace by running task with --trace) Levine_iMac$ bundle install rbenv: bundle: command not found The 'bundle' command exists in these Ruby versions: 2.1.1 Levine_iMac$

任何想法如何补救这个?谢谢。

+0

我试过了。现在我运行rake时出现这个错误:db migrate 'Levine_iMac $ rake db:migrate rake aborted! 无法加载此文件 - 打包程序/设置 /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in'' /Users/Levine_iMac/Dropbox/Coding /Sandbox/simple_cms2/config/application.rb:1:in'' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in'' (通过运行带有--trace任务查看完整的跟踪) Levine_iMac $捆绑安装 rbenv:包:找不到命令 的“捆绑”命令在这些Ruby版本存在: 2.1.1' – HPJAJ 2014-08-28 18:01:08

+0

有一个线索在最后line:“找不到命令'bundle'命令存在于这些Ruby版本中:2.1.1”。试试'gem install bundler'(升级红宝石后需要)。 – cydparser 2014-08-28 20:09:28

+0

工作。谢谢@paulwise!感谢所有贡献的人。 – HPJAJ 2014-08-28 20:42:11

回答

0

那么,当你运行rake db时,你准确地期望发生什么:migrate?下一步将为您实现吗?如果你能回答这个问题,你就会明白为什么你做的事情没有意义。

我会详细说明:

耙分贝:迁移只能在现有的Rails应用程序的环境。运行'gem install mysql2'会在你的计算机上为你获得这个库(这个命令本身执行,它实际上与Rails本身没有任何关系,或者需要Rails应用程序用于上下文)。所以,两者之间没有线性关系。

  1. 轨新的myapp在Gemfile中
  2. 添加 '宝石mysql2'
  3. 耙分贝:创建

,或者:

rails new myapp -d mysql 
+0

什么让你觉得他不在现有的Rails应用程序中? – JTG 2014-08-28 17:52:45

+0

无论他是否与他无关,因为'gem install mysql2'是一个与Rails应用程序无关的命令,它只是将库安装到您的计算机。运行rake db:在安装mysql2之前和之后在他的应用程序中迁移,将会输出相同的结果。 – ilrein 2014-08-28 17:58:46

+0

你好。我确实有一个现有的Rails应用程序,我一直在另一台计算机上工作。我在这台计算机上安装了所有东西,创建了相同的命名数据库,并且需要迁移来填充它。这是我得到错误的地方。 我试过上面再次安装Ruby的建议(由by,是从2.1.1 ..升级到2.1.2 ..)。现在我得到一个新的错误(上图)。 谢谢。 – HPJAJ 2014-08-28 18:07:07