I am working on Ubuntu 10.04 LTS, Lucid Lynx, have installed Ruby on Rails 3 on it. I am not able to start Rails server. I am getting the following error.
mah#mah-laptop:~/Desktop/projects/ver$ rails s
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.8/lib/rails/commands.rb:29:in `block in <top (required)>': undefined method `root' for nil:NilClass (NoMethodError)
from /home/mah/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.8/lib/rails/commands.rb:27:in `tap'
from /home/mah/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.8/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I am using Rails 3.0.8 and rake version 0.8.7
I tried bundle exec but got same error.
Thanks for any help in advance
UPDATE
Here is what I get after bundle exec rake db:migrate --trace
mah#mah-laptop:~/Desktop/projects/ver$ bundle exec rake db:migrate --trace
rake aborted!
uninitialized constant Ver
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library'
/home/mah/Desktop/projects/ver/Rakefile:7:in `<top (required)>'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/home/mah/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/home/mah/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `load'
/home/mah/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `<main>'
This error means that Rails.application isn't initialized. I didn't actually know that, I
cheated.
So that then begs the question: how did you set up this application?
Perhaps this application doesn't contain a config/application.rb file that defines a class that inherits from Rails::Application and therefore is causing this problem. In my application here, I've got this one you could use as an example.
Related
I've already seen some different answers, but none of these helped me...
This is the trick: I have to fix this without touching the Gemfile. I'm currently creating my working environment so that it matches the production server, so, I cannot modify the rails' code at all.
My OS: OSX 10.11
Ruby: ruby 2.0.0p643
Rails: 4.0.0
The gem is the Gemfile as gem 'mysql2'. There are no errors when doing bundle install, but when I try to rake db:migrate --trace this is the output:
rake aborted!
There was an error while trying to load the gem 'mysql2'.
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
/Users/redar/redar/config/application.rb:7:in `<top (required)>'
/Users/redar/redar/Rakefile:4:in `require'
/Users/redar/redar/Rakefile:4:in `<top (required)>'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/rake:23:in `load'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/rake:23:in `<main>'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `<main>'
I don't know how to interpret this. Is there something wrong with the Rakefile?
Also, this is the output from the mkmf.log
EDIT: This is the content of my Rakefile, located at myapp/folder
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
MyApp::Application.load_tasks
Try
bundle exec rake db:migrate
This will make sure that you are executing "rake db:migrate" with the gems listed in the Gemfile loaded and available. If you run it without "bundle exec" you may be executing only with the system gems available.
I'm trying to install Catarse.me on a Fedora 19 machine, ready to be pushed to Heroku.
I've managed to successfully run bundle install. But when I try
rake db:migrate
I receive this error
[root#acer]$ rake db:migrate
rake aborted!
undefined local variable or method `ext_dir' for #<Gem::Specification:0x450c8ce RedCloth-4.2.9>
/home/user/rails/catarse/config/boot.rb:7:in `<top (required)>'
/home/user/rails/catarse/config/application.rb:1:in `<top (required)>'
/home/user/rails/catarse/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
I've individually checked each of these files, and on the lines noted there's a call to
variablename = File.expand_path('../path/to/Gemfile', __FILE__)
CORRECTION The stack trace points to line 7 in book.rb
Bundler.setup
I've googled but the only relevant hit is this StackOverflow question but whose situation and answer is unrelated to my problem.
I'd appreciate the help.
Running rake db:migrate -- trace gives
rake aborted!
undefined local variable or method `ext_dir' for #<Gem::Specification:0x4700158 RedCloth-4.2.9>
/usr/local/share/ruby/site_ruby/rubygems/specification.rb:1887:in `method_missing'
/usr/share/gems/gems/bundler-1.3.1/lib/bundler/rubygems_ext.rb:42:in `load_paths'
/usr/share/gems/gems/bundler-1.3.1/lib/bundler/runtime.rb:37:in `block in setup'
/usr/share/gems/gems/bundler-1.3.1/lib/bundler/runtime.rb:19:in `setup'
/usr/share/gems/gems/bundler-1.3.1/lib/bundler.rb:120:in `setup'
/home/mei/rails/catarse/config/boot.rb:7:in `<top (required)>'
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/mei/rails/catarse/config/application.rb:1:in `<top (required)>'
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/mei/rails/catarse/Rakefile:4:in `<top (required)>'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/share/gems/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/usr/local/share/gems/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/bin/rake:23:in `load'
/bin/rake:23:in `<main>'
By your trace, it seems like it's a bundler issue,
running
gem update bundler
should fix it.
I just upgraded from ruby 1.9.3-p194 to 1.9.3-p286 via the rvm upgrade command and the gemset. Now when I run rake rails upgrade on my rails app it gives me the following trace:
nosh#nosh-VirtualBox:~/Projects/icon$ rake rails update --trace
rake aborted!
cannot load such file -- ruby_debug.so
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/ruby-debug-base19-0.11.26/lib/ruby-debug-base.rb:1:in `require'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/ruby-debug-base19-0.11.26/lib/ruby-debug-base.rb:1:in `<top (required)>'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `block in require'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
/home/nosh/Projects/icon/config/application.rb:7:in `<top (required)>'
/home/nosh/Projects/icon/Rakefile:5:in `require'
/home/nosh/Projects/icon/Rakefile:5:in `<top (required)>'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/bin/rake:19:in `load'
/home/nosh/.rvm/gems/ruby-1.9.3-p286#global/bin/rake:19:in `<main>'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `eval'
/home/nosh/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `<main>'
Any suggestions are appreciated. If its the ruby version conflict with ruby debug 19 gem. Then how should I downgrade back to 1.9.3-p194.
I guess I just had to try it; but the same rvm command that allows the upgrade also allows downgrade. So the following command allowed me to downgrade to the previous version:
rvm upgrade 1.9.3-p286 1.9.3-p194
It migrated the gems as well.
By the way I also found out after the downgrade that the rake rails update command I used had incorrect syntax.
So this is incorrect:
rake rails update --trace (incorrect)
This is correct:
rake rails:update --trace (correct)
I did not get the error after the upgrade again, that means I was probably using the wrong syntax.
Anyone could help me?
I searched the same problem, but I can't figure out a solution still.
I ran successfully with "bundle update" "bundle install" but when running "rake db:migrate" I got the following problem...
rake aborted!
uninitialized constant Rake::DSL
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:8:in `<clas
s:TaskLib>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:6:in `<modu
le:Rake>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:3:in `<top
(required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rdoc-3.11/lib/rdoc/task.rb:37:in `<top (requ
ired)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation
.rake:2:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `blo
ck in <top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each
'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `<top
(required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:
in `initialize_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:139:
in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:i
n `method_missing'
C:/F/desktop/Projects/recle/recle/rails/eway/Rakefile:7:in `<top (required)>'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `load'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in `run'
C:/Ruby192/bin/rake:31:in `<main>'
Put this in your Rakefile above require 'rake':
require 'rake/dsl_definition'
OR if the above solution does not work,
write this in your gemfile for rake
gem "rake", "0.8.7"
and go to command prompt and write.
gem uninstall rake
This will uninstall the existing rake gem.
Then type bundle update in your project folder which will install rake 9.8.7 again.
And enjoy rails :).
When i am running rake db:migrate i am getting the following error . Please let me know the reason.
Environment - Windows 7 Home Premium
Rails
F:/ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
F:/ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
F:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
F:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
F:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
F:/example/ROR//vendor/plugins/savage-beast/lib/tasks/savage_beast.rake:2
F:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
F:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load'
F:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
F:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load'
F:/ruby187/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:13
F:/ruby187/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:13:in `each'
F:/ruby187/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:13
F:/ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
F:/ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
F:/example/ROR/Rakefile:10
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
F:/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
F:/Ruby187/bin/rake:19:in `load'
F:/Ruby187/bin/rake:19
It seems that Rails gem is not installed properly because Rake:db create is a Rails method and it seems in your case that it is not running properly.
You can refer this
Step By Step Installer
You could try the following command rake db:create:all followed by rake db:migrate You coudl get this error if you have no databses setup for your project. And do you have a database.yml file in your app/config folder?