/ / Rails non può usare rake db: create? - mysql, ruby-on-rails, ruby

Rails non può usare rake db: create? - mysql, ruby-on-rails, ruby

Ho seguito questo tutorial: http://cicolink.blogspot.nl/2011/06/how-to-install-ruby-on-rails-3-with.html e sto facendo quanto segue:

$ rails new ourapp -d=mysql
$ cd ourapp/
$ rake:dbcreate/

Il mio gemfile è:

source "https://rubygems.org"

# Bundle edge Rails instead: gem "rails", github: "rails/rails"
gem "rails", "4.0.0"

# Use mysql as the database for Active Record
gem "mysql2", "~> 0.2.7"

# Use SCSS for stylesheets
gem "sass-rails", "~> 4.0.0"

# Use Uglifier as compressor for JavaScript assets
gem "uglifier", ">= 1.3.0"

# Use CoffeeScript for .js.coffee assets and views
gem "coffee-rails", "~> 4.0.0"

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem "therubyracer", platforms: :ruby

# Use jquery as the JavaScript library
gem "jquery-rails"

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem "turbolinks"

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem "jbuilder", "~> 1.2"

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem "sdoc", require: false
end

# Use ActiveModel has_secure_password
# gem "bcrypt-ruby", "~> 3.0.0"

# Use unicorn as the app server
# gem "unicorn"

# Use Capistrano for deployment
# gem "capistrano", group: :development

# Use debugger
# gem "debugger", group: [:development, :test]

Sto ricevendo il seguente errore:

rake aborted!
cannot load such file -- mysql2/mysql2
/root/Development/Rails/ourapp/config/application.rb:7:in `<top (required)>"
/root/Development/Rails/ourapp/Rakefile:4:in `<top (required)>"
(See full trace by running task with --trace)

Ecco una traccia:

rake db:create --trace
rake aborted!
cannot load such file -- mysql2/mysql2
/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.2.20/lib/mysql2.rb:8:in `require"
/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.2.20/lib/mysql2.rb:8:in `<top (required)>"
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require"
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require"
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each"
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require"
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each"
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require"
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require"
/root/Development/Rails/ourapp/config/application.rb:7:in `<top (required)>"
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require"
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require"
/root/Development/Rails/ourapp/Rakefile:4:in `<top (required)>"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run"
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>"
/usr/local/bin/rake:23:in `load"
/usr/local/bin/rake:23:in `<main>"

Come posso risolvere questo?

risposte:

1 per risposta № 1

Prova ad aggiornare RubyGems con gem update --system (c'è un bug con RubyGems 1.8.x su Ruby 2.0)


0 per risposta № 2

Correre bundle install

Quindi controlla il tuo Gemfile e controlla se mysql2 è lì. Non hai bisogno del mysql gemma


-1 per risposta № 3

Controlla se il rake funziona correttamente?