简体   繁体   中英

Uninitialized constant RAILS_ROOT: Surveyor gem and using Rails.root

I'm trying to set up the surveyor gem using the installation guide provided. I am working from the surveyor-example that is available here , so I assumed I would be working from older code. However, when I run

bundle exec rake surveyor FILE=surveys/kitchen_sink_survey.rb

It comes up with the error "uninitialized constant RAILS_ROOT". I read here that a solution to this is to try using Rails.root , but I'm not sure where to change this setting. Is this something I set in environment.rb or within the survey code itself?

If it provides any futher help, here's the result of the trace:

/home/nitrous/surveyor_example/.bundle/bundler/gems/surveyor-a95169e36afc/lib/tasks/surveyor_tasks.rake:7:in `block (2 levels) in <top (required)>'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/home/nitrous/surveyor_example/.bundle/bin/rake:23:in `load'
/home/nitrous/surveyor_example/.bundle/bin/rake:23:in `<main>'

The error is coming from the version of the surveyor gem you are using. surveyor-a95169e36afc refers to an older version.

In your Gemfile make sure you just have

gem 'surveyor'

and bundle install

once that is set , it should install surveyor 0.20.0 which will work with your version of rails.

The Gemfile included in the tutorial is out of date/for a different version of rails.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM