尝试在 Ruby 1.9.3、Rails 3.2.7、mstwjs Noel Rappin 教程应用程序中加载 gem 'mysql2' 时出错
error while trying to load the gem 'mysql2' in Ruby 1.9.3, Rails 3.2.7, mstwjs Noel Rappin tutorial app
我正尝试通过 Noel Rappin's very promising "Master Space and Time with JavaScript." One hurdle stems from the fact that the code 上次更新于 2012 年 9 月开始工作,生态系统也在不断发展。我相信我的问题主要源于 mysql 数据库,使用自制软件安装它(我相信默认情况下是最新版本)和 mysql2 gem 版本 Mr. Rappin 在什么时候用过12、0.3.11.
我更新了 Gemfile 以反映 mstwjs Gemfile.lock 文件中的 gem 版本:
source 'http://rubygems.org'
gem 'rails', '3.2.7'
gem 'devise', '2.1.2'
# Bundle edge Rails instead:
#gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '0.3.11'
# Asset template engines
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.6'
end
gem 'jquery-rails', '2.0.2'
gem 'rails-backbone', '0.7.2'
#gem 'sprockets_spacely'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :development do
gem 'powder', '0.1.8'
gem 'awesome_print', '1.0.2'
gem 'annotate', '2.5.0'
end
group :test, :development do
#gem 'guard-rails-assets'
#gem 'guard-jasmine-headless-webkit'
gem 'jasmine-headless-webkit', '0.8.4'
gem 'jasmine', '1.2.0'
gem 'jasminerice', '0.0.9'
gem 'rspec-rails', '2.11.0'
end
然后
$ rbenv local use 1.9.3
$ brew install mysql2
$ gem install mysql2 -v ‘0.3.11’
$ bundle install
到目前为止一切顺利!
当我尝试 运行 mstwjs 设置生成器时:
$ rake mstwjs:setup --trace
我运行进入如下错误:
rake aborted!
There was an error while trying to load the gem 'mysql2'.
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:81:in `rescue in block (2 levels) in require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
/Users/benjaminunger/programming/rails/mstwjs/config/application.rb:7:in `<top (required)>'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/benjaminunger/programming/rails/mstwjs/Rakefile:5:in `<top (required)>'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/bin/rake:32:in `<main>'
有人知道我做错了什么吗?非常感谢您的见解。
我通过进行以下更改设法让回购工作:
# Gemfile
gem 'mysql2', '~> 0.3.20'
bundle update mysql2
# Create config/initializers/abstract_mysql2_adapter.rb
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end
bundle exec rake mstwjs:setup --trace
成功了。
我正尝试通过 Noel Rappin's very promising "Master Space and Time with JavaScript." One hurdle stems from the fact that the code 上次更新于 2012 年 9 月开始工作,生态系统也在不断发展。我相信我的问题主要源于 mysql 数据库,使用自制软件安装它(我相信默认情况下是最新版本)和 mysql2 gem 版本 Mr. Rappin 在什么时候用过12、0.3.11.
我更新了 Gemfile 以反映 mstwjs Gemfile.lock 文件中的 gem 版本:
source 'http://rubygems.org'
gem 'rails', '3.2.7'
gem 'devise', '2.1.2'
# Bundle edge Rails instead:
#gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '0.3.11'
# Asset template engines
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.6'
end
gem 'jquery-rails', '2.0.2'
gem 'rails-backbone', '0.7.2'
#gem 'sprockets_spacely'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :development do
gem 'powder', '0.1.8'
gem 'awesome_print', '1.0.2'
gem 'annotate', '2.5.0'
end
group :test, :development do
#gem 'guard-rails-assets'
#gem 'guard-jasmine-headless-webkit'
gem 'jasmine-headless-webkit', '0.8.4'
gem 'jasmine', '1.2.0'
gem 'jasminerice', '0.0.9'
gem 'rspec-rails', '2.11.0'
end
然后
$ rbenv local use 1.9.3
$ brew install mysql2
$ gem install mysql2 -v ‘0.3.11’
$ bundle install
到目前为止一切顺利! 当我尝试 运行 mstwjs 设置生成器时:
$ rake mstwjs:setup --trace
我运行进入如下错误:
rake aborted!
There was an error while trying to load the gem 'mysql2'.
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:81:in `rescue in block (2 levels) in require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
/Users/benjaminunger/programming/rails/mstwjs/config/application.rb:7:in `<top (required)>'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/benjaminunger/programming/rails/mstwjs/Rakefile:5:in `<top (required)>'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/Users/benjaminunger/.rbenv/versions/1.9.3-p551/bin/rake:32:in `<main>'
有人知道我做错了什么吗?非常感谢您的见解。
我通过进行以下更改设法让回购工作:
# Gemfile
gem 'mysql2', '~> 0.3.20'
bundle update mysql2
# Create config/initializers/abstract_mysql2_adapter.rb
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end
bundle exec rake mstwjs:setup --trace
成功了。