我似乎无法让mysql与我的新rails应用程序一起使用...下面的终端副本:
Janes-MacBook-Pro:development janelee$ cd hellomysql
Janes-MacBook-Pro:hellomysql janelee$ rails server
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): no suitable image found. Did find: (LoadError)
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2.rb:9
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
from /Users/janelee/Development/hellomysql/config/application.rb:7
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:53
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6
Janes-MacBook-Pro:hellomysql janelee$ rake db:migrate
rake aborted!
dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): no suitable image found. Did find:
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
(See full trace by running task with --trace)
我也尝试了这个:
Janes-MacBook-Pro:hello janelee$ gem uninstall sqlite3
You have requested to uninstall the gem:
sqlite3-1.3.5
i18n-0.6.0 depends on [sqlite3 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y
Successfully uninstalled sqlite3-1.3.5
Janes-MacBook-Pro:hello janelee$ ARCHFLAGS="-arch x86_32" sudo gem install sqlite3
Password:
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.5
1 gem installed
Janes-MacBook-Pro:hello janelee$ rake db:migrate
rake aborted!
dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle, 9): no suitable image found. Did find:
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle
(See full trace by running task with --trace)
和此:
Janes-MacBook-Pro:hello janelee$ gem uninstall sqlite3
You have requested to uninstall the gem:
sqlite3-1.3.5
i18n-0.6.0 depends on [sqlite3 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y
Successfully uninstalled sqlite3-1.3.5
Janes-MacBook-Pro:hello janelee$ ARCHFLAGS="-arch x86_64" sudo gem install sqlite3
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.5
1 gem installed
Janes-MacBook-Pro:hello janelee$ rake db:migrate
rake aborted!
dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle, 9): no suitable image found. Did find:
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle
(See full trace by running task with --trace)
重新安装Lion之前我还应该尝试什么?
答案 0 :(得分:1)
使用Ruby Version Manager(称为rvm)然后更新Ruby。尝试使用very 1.9或更高版本。不要重新安装您的操作系统。如果有的话,删除铁轨,删除红宝石。安装rvm,安装ruby 1.9,安装rails。如果你遵循那个食谱,一切都应该是好的。
通过更改文件来配置Rails以使用MySQL:
myappname/config/database.yml
这里提供的信息很好:How do I set MySQL as the default database in Rails 3?
......在这里:Create a new Ruby on Rails application using MySQL instead of SQLite
习惯查看Rails指南。像这样的例子:http://guides.rubyonrails.org/getting_started.html#configuring-a-database就是你需要的。