我正在制作我的第二个Ruby项目,只是在这里学习,但是当我创建一个新的rails项目然后进入文件夹并输入
rails server
我收到此错误:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle:
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9):
Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in 'require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in 'require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in 'each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in 'require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in 'each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in 'require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler.rb:122:in 'require'
from /Users/memin/Sites/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:53:in 'require'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:53
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:50:in 'tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:50
from script/rails:6:in 'require'
from script/rails:6
这很奇怪,因为我有一个不同的项目运行良好,但这个错误让我傻眼。
答案 0 :(得分:0)
我花了不少于3个小时来解决这个问题 - 在不少于4个“解决方案”之后,这是问题的永久解决方案,至少对我而言。现在一切都有效。你快到了!!不要放弃!
将这段代码放在.profile和.bash_profile文件中。如果您不知道如何操作,请在每次打开时在终端中输入...
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
* * 好的,好的,这就是我的.bash_profile的样子:
alias ll="ls -lahG"
alias whereami="pwd"
export PATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/my$
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
要修改bash,请在根($)终端菜单中输入“ls -la
”,然后输入nano .bash_profile
和/或nano .profile
进入菜单。完成编辑后,点击ctrl-X,然后“返回”返回主菜单,可以这么说。祝你好运!