LoadError no such file when trying to load gems under rails - ruby-on-rails-3

I'm getting a 'no such file' error when I try to require some gems in a rails console. Strangely, I don't get this error when requiring them in irb.
Thanks in advance.
$ irb
irb(main):001:0> $LOAD_PATH
=> ["/usr/local/lib/site_ruby/1.9.1", "/usr/local/lib/site_ruby/1.9.1/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.9.1", "/usr/lib/ruby/vendor_ruby/1.9.1/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.9.1", "/usr/lib/ruby/1.9.1/x86_64-linux"]
irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'image_science'
=> true
irb(main):004:0> require 'mini_magick'
=> true
irb(main):005:0>
$ rails console
Loading development environment (Rails 3.0.5)
irb(main):001:0> require 'rubygems'
=> nil
irb(main):002:0> require 'image_science'
LoadError: no such file to load -- image_science
from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
...
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):003:0> require 'mini_magick'
LoadError: no such file to load -- mini_magick
from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
...
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):004:0> $LOAD_PATH
=> ["/var/lib/gems/1.9.1/gems/haml-3.0.25/vendor/fssm/lib", "/home/username/appname/lib", "/home/username/appname/vendor", "/home/username/appname/app/models", "/home/username/appname/app/mailers", "/home/username/appname/app/helpers", "/home/username/appname/app/controllers", "/var/lib/gems/1.9.1/gems/rails-3.0.5/lib", "/var/lib/gems/1.9.1/gems/railties-3.0.5/lib", "/var/lib/gems/1.9.1/gems/thor-0.14.6/lib", "/var/lib/gems/1.9.1/gems/pg-0.10.1/lib", "/var/lib/gems/1.9.1/gems/pg-0.10.1/ext", "/var/lib/gems/1.9.1/gems/oauth2-0.1.1/lib", "/var/lib/gems/1.9.1/gems/multi_json-0.0.5/lib", "/var/lib/gems/1.9.1/gems/haml-3.0.25/lib", "/var/lib/gems/1.9.1/gems/faraday-0.5.7/lib", "/var/lib/gems/1.9.1/gems/multipart-post-1.1.0/lib", "/var/lib/gems/1.9.1/gems/addressable-2.2.4/lib", "/var/lib/gems/1.9.1/gems/activeresource-3.0.5/lib", "/var/lib/gems/1.9.1/gems/activerecord-3.0.5/lib", "/var/lib/gems/1.9.1/gems/arel-2.0.9/lib", "/var/lib/gems/1.9.1/gems/actionmailer-3.0.5/lib", "/var/lib/gems/1.9.1/gems/mail-2.2.15/lib", "/var/lib/gems/1.9.1/gems/treetop-1.4.9/lib", "/var/lib/gems/1.9.1/gems/polyglot-0.3.1/lib", "/var/lib/gems/1.9.1/gems/mime-types-1.16/lib", "/var/lib/gems/1.9.1/gems/actionpack-3.0.5/lib", "/var/lib/gems/1.9.1/gems/tzinfo-0.3.24/lib", "/var/lib/gems/1.9.1/gems/rack-test-0.5.7/lib", "/var/lib/gems/1.9.1/gems/rack-mount-0.6.13/lib", "/var/lib/gems/1.9.1/gems/rack-1.2.1/lib", "/var/lib/gems/1.9.1/gems/erubis-2.6.6/lib", "/var/lib/gems/1.9.1/gems/activemodel-3.0.5/lib", "/var/lib/gems/1.9.1/gems/i18n-0.5.0/lib", "/var/lib/gems/1.9.1/gems/builder-2.1.2/lib", "/var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib", "/var/lib/gems/1.9.1/gems/abstract-1.0.0/lib", "/var/lib/gems/1.9.1/gems/rake-0.8.7/lib", "/var/lib/gems/1.9.1/gems/bundler-1.0.10/lib", "/usr/local/lib/site_ruby/1.9.1", "/usr/local/lib/site_ruby/1.9.1/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.9.1", "/usr/lib/ruby/vendor_ruby/1.9.1/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.9.1", "/usr/lib/ruby/1.9.1/x86_64-linux", "/var/lib/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/vendor/html-scanner", "/var/lib/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/vendor/multimap", "/var/lib/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/vendor/regin"]
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'pg'
gem 'oauth2'
gem 'haml'

You cannot require gems in Rails that are not in your Gemfile. You have to either include them in your Gemfile, or specify the full path to the gem when requiring, e.g. require "/full/path/to/gem".
This is because of the way Bundler works and overrides your existing load path. If you run $LOAD_PATH in the Rails console you'll see that it differs significantly from the one in IRB.

Related

Spork and Guard EADDRINUSE

I'm building a rails app and using Spork/Guard/Rspec for testing.
I'm on a mac (10.6.8) -- here are the gems I'm using:
gem "rspec-rails", "~> 2.12.1"
gem "guard-rspec", "~> 2.3.3"
gem "guard-spork", "~> 1.4.1"
gem "spork", "~> 0.9.2"
gem 'rb-fsevent', '~> 0.9.1', :require => false
gem "growl", "~> 1.0.3"
gem 'capybara', '1.1.2'
When I edit my routes file it should restart the spork server here's the line in my Guardfile:
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, :foreman => true do
watch('config/routes.rb')
end
But recently I just started getting the following error when I add a new route:
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Address already in use - bind(2) (Errno::EADDRINUSE)
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `initialize'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `open'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:759:in `block in open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:757:in `each'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:757:in `open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1342:in `initialize'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1624:in `new'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1624:in `start_service'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/server.rb:29:in `listen'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/server.rb:20:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/runner.rb:75:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/runner.rb:10:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/bin/spork:10:in `<top (required)>'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/bin/spork:23:in `load'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/bin/spork:23:in `<main>'
Usually when spork boots up I get the following:
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Spork is ready and listening on 8989!
How do I avoid this error?
I came here suffering the same problem as the OP.
After going down the rabbit hole of the 'error is a bug' post, and examining the line of code where the failure occurred, I rebooted out of frustration. I realized after doing this that the lock on the port likely came from the fact that I had logged out of the previous desktop session, and that the Spork DRb server hangs RubyMine on closing, so maybe that is what leaves the port open.
Sure enough, I could now start the Spork server.
I add this so other people facing this problem can consider if it matches their situation.
By removing the :foreman => true in the Guardfile I was able to get rid of this problem. Right now I'm not making meaningful use of the values in my .env file in my tests so that should be fine, but I'm submitting an issue on Github.
Looks like this error is a bug: https://github.com/rails/rails/pull/8812

DeviseCreateUsers: migrating create_table(:users) rake aborted

I encountered the following error while running rake db:migrate --trace. my rails version - rails 3.2.0. And i am trying to run the project https://github.com/ninetwentyfour/Hospitium. I am newbie to ruby to ruby on rails
errors:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Invoke disable_rails_admin_initializer (first_time)
** Execute disable_rails_admin_initializer
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== **DeviseCreateUsers: migrating** ==============================================
-- **create_table(:users)**
**rake aborted!
An error has occurred, all later migrations canceled:
undefined method `database_authenticatable'** for #<ActiveRecord::ConnectionAdapte
rs::TableDefinition:0x5d49098>
E:/ruby projects/Hospitium Animal Hospital/db/migrate/20110904205556_devise_crea
te_users.rb:4:in `block in up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect
ion_adapters/abstract/schema_statements.rb:160:in `create_table'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect
ion_adapters/abstract_mysql_adapter.rb:422:in `create_table'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:450:in `block in method_missing'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:424:in `block in say_with_time'
C:/Ruby193/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:424:in `say_with_time'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:444:in `method_missing'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:334:in `method_missing'
E:/ruby projects/Hospitium Animal Hospital/db/migrate/20110904205556_devise_crea
te_users.rb:3:in `up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:358:in `up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:396:in `block (2 levels) in migrate'
C:/Ruby193/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:396:in `block in migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect
ion_adapters/abstract/connection_pool.rb:118:in `with_connection'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:377:in `migrate'
C:in `migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:704:in `block (2 levels) in migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:761:in `call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:761:in `ddl_transaction'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:703:in `block in migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:684:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:684:in `migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:554:in `up'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati
on.rb:535:in `migrate'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/railtie
s/databases.rake:153:in `block (2 levels) in <top (required)>'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `call'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_lev
el'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin
g'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin
g'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
C:/Ruby193/bin/rake:32:in `<main>'
Tasks: TOP => db:migrate
My GEM file
source 'http://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem "eventmachine", "1.0.0.beta.4.1"
gem 'mysql2'
gem 'devise' # Devise must be required before RailsAdmin
gem 'rails_admin'
gem 'nokogiri'
gem 'mechanize'
gem 'uuidtools'
gem 'cancan'
gem 'paperclip'
gem 'aws-sdk', '~> 1.3.4'
gem 'will_paginate'
gem 'paper_trail'
gem 'oauth'
#gem 'twitter'
gem 'rest-client'
gem 'json'
#gem 'libxml-xmlrpc'
gem 'bitly'
gem 'site_meta'
gem 'meta_search'
gem 'airbrake'
gem 'spork', '~> 1.0rc'
gem 'client_side_validations'
gem 'jqplot-rails'
gem 'asset_sync'
gem 'gravatar_image_tag'
gem 'best_in_place'
gem 'juggernaut'
gem 'jquery-rails'
#gem 'less-rails-bootstrap'
gem "spreadsheet", "0.6.5.8"
gem 'to_xls'
gem 'sanitize'
gem 'redcarpet'
gem 'rqrcode-rails3'
gem 'octokit'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'closure-compiler'
end
group :development do
gem 'metrical'
end
group :production do
gem 'home_run', :require=>'date'
#gem 'slim_scrooge', :git => "git://github.com/sdsykes/slim_scrooge.git"
gem 'dalli'
gem 'thin'
gem 'pg'
gem 'newrelic_rpm'
gem 'heroku'
end
gem "rspec-rails", :group => [:test, :development]
group :test do
gem "factory_girl_rails"
gem "capybara"
#gem 'capybara-webkit'
gem 'shoulda-matchers'
gem 'cucumber-rails', :require => false
gem 'database_cleaner'
gem 'launchy'
gem 'email_spec'
end
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
----------------------------------------------------------------------------------------
as per Said Kaldybaev solution , i tried
E:\ruby projects\Hospitium Animal Hospital>rails g devise:install
conflict config/initializers/devise.rb
Overwrite E:/ruby projects/Hospitium Animal Hospital/config/initializers/devise.
rb? (enter "h" for help) [Ynaqdh] h
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
Overwrite E:/ruby projects/Hospitium Animal Hospital/config/initializers/devise.
rb? (enter "h" for help) [Ynaqdh] a
force config/initializers/devise.rb
identical config/locales/devise.en.yml
===============================================================================
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options in your environments files. Her
e
is an example of default_url_options appropriate for a development environm
ent
in config/environments/development.rb:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root :to => "home#index"
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
If you are deploying Rails 3.1 on Heroku, you may want to set:
config.assets.initialize_on_precompile = false
On config/application.rb forcing your application to not access the DB
or load models when precompiling your assets.
===============================================================================
E:\ruby projects\Hospitium Animal Hospital>rails g devise user
invoke active_record
Another migration is already named add_devise_to_users: E:/ruby projects/Hospiti
um Animal Hospital/db/migrate/20120518093709_add_devise_to_users.rb
E:\ruby projects\Hospitium Animal Hospital>rake db:migrate
== DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `database_authenticatable' for #
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
It seems to problem with that repo at that time, https://github.com/ninetwentyfour/Hospitium,
now its working fine.

undefined method `database_authenticatable' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x9dee690>

I am using Active Admin gem for my small application based on Quiz. But when I execute rake db:migrate it gives me error. Following is the trace of the command :
$ rake db:migrate RAILS_ENV=production --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== DeviseCreateAdminUsers: migrating =========================================
-- create_table(:admin_users)
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `database_authenticatable' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x9dee690>
/home/users/Documents/Quiz/db/migrate/20120509055635_devise_create_admin_users.rb:4:in `block in change'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/connection_adapters /abstract_mysql_adapter.rb:432:in `create_table'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:466:in `block in method_missing'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:438:in `block in say_with_time'
/home/users/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:438:in `say_with_time'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:458:in `method_missing'
/home/users/Documents/Quiz/db/migrate/20120509055635_devise_create_admin_users.rb:3:in `change'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:407:in `block (2 levels) in migrate'
/home/users/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:407:in `block in migrate'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:119:in `with_connection'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:389:in `migrate'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:528:in `migrate'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:777:in `call'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:777:in `ddl_transaction'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:719:in `block in migrate'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:700:in `each'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:700:in `migrate'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:570:in `up'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/migration.rb:551:in `migrate'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.2.3/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/users/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/users/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/users/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `load'
/home/users/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate
Follwoing is my GemFile :
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'devise'
gem 'activeadmin', :git => 'https://github.com/gregbell/active_admin.git'
gem 'therubyracer'
gem 'formtastic'
gem 'haml'
gem 'paperclip'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Content of 20120509055635_devise_create_admin_users.rb is
class DeviseCreateAdminUsers < ActiveRecord::Migration
def change
create_table(:admin_users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.encryptable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
# Create a default user
AdminUser.create!(:email => 'admin#example.com', :password => 'password', :password_confirmation => 'password')
add_index :admin_users, :email, :unique => true
add_index :admin_users, :reset_password_token, :unique => true
# add_index :admin_users, :confirmation_token, :unique => true
# add_index :admin_users, :unlock_token, :unique => true
# add_index :admin_users, :authentication_token, :unique => true
end
end
I searched for the above issue and got this , but this doesn't helped me out. Everywhere I found this solution only.
Does any one came across this issue before, if yes what you did to tackle it? Any help on this will be appreciated. Thanks
I also ran into this issue on my existing app as I tried to deploy to a new staging server.
Ended up being that the Devise gem had been updated to 2.1 and I hadn't fixed the migration to work correctly with the new version.
Be sure to read through their migration to 2.1 doc on their wiki -- https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.1
Also, be sure to read through the doc for how to correctly adjust existing migrations -- https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style
I've run into this twice and there is a really easy solution - instead of db migrations, run this:
heroku run rake db:create
# optionally with --app your_apps_name if you have multiple apps.
then:
rake db:schema:load
I just had what I think is the same issue, I updated my gem, and dropped my db, later I got a very similar message, then I created a new rails app just to compare and it turns out the migration file has been changed, now it includes the columns instead of calling methods.
I hope it helps.
Cheers!
I think the problem might be as result of changes in Devise 2.0 migration schema style. Check out new schema format on the link below. Update migration accordingly and try again. This worked for me especially with #heroku
https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style
New to this site as you can see from my rep. John Kamuchau is correct, you need to change the xxxx_devise_create_users.rb migration according to your version.
For example I just updated a rails 3.2 to 4.2 updating devise accordingly and I had to change out the deprecated -
t.database_authenticatable :null => false
for -
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
Old question but hope this helps if someone comes looking.

rails generate rspec:install - no such file to load -- sqlite3/sqlite3_native (LoadError)

I'm trying to follow this tutorial, and when I try to use the RSpec generator
$ rails generate rspec:install
I get the following error:
/usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.5/lib/sqlite3.rb:6:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
from /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.5/lib/sqlite3.rb:6
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
from /home/rcooke/sample_app/config/application.rb:13
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.2/lib/rails/commands.rb:24:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.2/lib/rails/commands.rb:24
from script/rails:6:in `require'
from script/rails:6
Following the other discussions on this same problem, I have changed my Gemfile to contain the following:
group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'sqlite3', '1.3.5'
gem 'rspec-rails'
gem 'rspec'
end
I added both rspec and rspec-rails to the Gemfile after noticing they are both installed:
Using rspec-core (2.9.0)
Using rspec-expectations (2.9.0)
Using rspec-mocks (2.9.0)
Using rspec (2.9.0)
Using rspec-rails (2.9.0)
I've even carried out:
$ gem install rspec
Maybe i'm not using the correct procedure to update. Once I've saved the Gemfile on my computer i'm using bundle update and bundle install. Trying rails generate rspec:install still fails.
Update: when I try to run the resource i get the following error:
$ rake spec
rake aborted!
no such file to load -- sqlite3/sqlite3_native
Update: I've obviously screwed something up. Now if I attempt to start a new application I get the following error.
$ rails new sample_app2 --skip-test-unit
/usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find json (~> 1.4) amongst [actionmailer-3.2.2, actionpack-3.2.2, activemodel-3.2.2, activerecord-3.2.2, activeresource-3.2.2, activesupport-3.2.2, addressable-2.2.7, arel-3.0.2, builder-3.0.0, bundler-1.1.3, bundler-1.1.2, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.2.0, diff-lcs-1.1.3, erubis-2.7.0, execjs-1.3.0, heroku-2.22.0, heroku-2.21.3, hike-1.2.1, i18n-0.6.0, journey-1.0.3, jquery-rails-2.0.1, json_pure-1.6.6, launchy-2.1.0, mail-2.4.4, mime-types-1.18, multi_json-1.2.0, multi_json-1.1.0, netrc-0.7.1, polyglot-0.3.3, rack-1.4.1, rack-cache-1.2, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.2.2, railties-3.2.2, rake-0.9.2.2, rdoc-3.12, rest-client-1.6.7, rspec-2.9.0, rspec-core-2.9.0, rspec-expectations-2.9.0, rspec-mocks-2.9.0, rspec-rails-2.9.0, rubyzip-0.9.6.1, sass-3.1.15, sass-rails-3.2.5, sprockets-2.3.1, sprockets-2.1.2, sqlite3-1.3.5, sqlite3-ruby-1.3.3, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, tzinfo-0.3.32, uglifier-1.2.3] (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:772:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:745:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:775:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:745:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1211:in `gem'
from /usr/bin/rails:18
Do you have the SQlite3 library installed on your system? When you look in /usr/lib/ for libsqlite3.so (assuming you're on Linux) do you see it? if not then could you try installing it (via apt-get/portage/your package manager) and see if that helps.

Undefined method `omniauth' for Devise:Module (devise, omniauth, heroku, rails 3.0.3)

I have an app that uses Amazon Product Advertising API at local with no issues. In order to push it to Heroku, I have to change the version of the aws gem I use to make it work with Heroku ("treyconnell-ruby-aaws" v0.8.3) and that version limits me to Rails 3.0.3 and to devise v1.1.8 gems.
When I downgrade gems and 'bundle update', something breaks even at local, guessing omniauth and devise start fighting. The server fail to starts with the following error log.
I tried many different configurations of loading omniauth gem, oa-auth, requiring omniauth/oauth etc, still the same error. What might be the issue here?
PS. I have to use this aws gem for now.
/Users/eerdogan/Sites/myApp/config/initializers/devise.rb:17: undefined method `omniauth' for Devise:Module (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/devise-1.1.8/lib/devise.rb:183:in `setup'
from /Users/eerdogan/Sites/myApp/config/initializers/devise.rb:3
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:201
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:200:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:200
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /Users/eerdogan/Sites/myApp/config/environment.rb:5
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /Users/eerdogan/Sites/myApp/config.ru:3
from /Library/Ruby/Gems/1.8/gems/rack-1.2.4/lib/rack/builder.rb:46:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/rack-1.2.4/lib/rack/builder.rb:46:in `initialize'
from /Users/eerdogan/Sites/myApp/config.ru:1:in `new'
from /Users/eerdogan/Sites/myApp/config.ru:1
Edit: here is the devise.rb file:
# Use this hook to configure devise mailer, warden hooks and so forth. The first
# four configuration values can also be set straight in your models.
Devise.setup do |config|
config.mailer_sender = "please-change-me-at-config-initializers-devise#example.com"
require 'devise/orm/active_record'
config.omniauth :facebook, "1*************", "3******************************"
config.case_insensitive_keys = [ :email ]
config.stretches = 10
config.use_salt_as_remember_token = true
config.reset_password_within = 2.hours
end
I think the config.facebook line in devise.rb is causing you the grief.
I took a look at my devise.rb and I also have another file called omniauth.rb.
(1) My devise.rb does not have the config.facebook line. Try removing that and see if it works.
(2) I have a file called omniauth.rb, located in the same directory as devise.rb. I'm pasting it below:
require 'openid/store/filesystem'
Rails.application.config.middleware.use OmniAuth::Builder do
case Rails.env
when "development"
provider :facebook, 'XXX', 'XXXX' , {:scope => 'manage_pages,publish_stream,offline_access,email'}
when "production"
provider :facebook, 'XXX', 'XXXX', {:scope => 'manage_pages,publish_stream,offline_access,email', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
end
end
See if this works out for you. :)