Rspec, Spork, & Autotest Error - ruby-on-rails

I'm trying to teach myself rails by going through http://railstutorial.org/. I quit working on the tutorial app last night and then came back to it today. Now I'm getting an error when I start up the Spork server. Here is a trace of the error.
spork Using RSpec Loading Spork.prefork block... can't convert nil into Hash (TypeError) /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0/lib/active_model/validations/validates.rb:90:in merge' /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0/lib/active_model/validations/validates.rb:90:invalidates' /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0/lib/active_model/validations/validates.rb:83:in each' /usr/local/lib/ruby/gems/1.8/gems/activemodel-3.0.0/lib/active_model/validations/validates.rb:83:invalidates' /Users/chietala/Desktop/rails_projects/sample_app/app/models/user.rb:20 /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:454:in load' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:454:inload_file' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in new_constants_in' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:453:inload_file' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:340:in require_or_load' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:300:independ_on' /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:216:in require_dependency' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/engine.rb:138:ineager_load!' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/engine.rb:137:in each' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/engine.rb:137:ineager_load!' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/engine.rb:135:in each' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/engine.rb:135:ineager_load!' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/application.rb:108:in eager_load!' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/application/finisher.rb:41 /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/initializable.rb:25:ininstance_exec' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/initializable.rb:25:in run' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/initializable.rb:50:inrun_initializers' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/initializable.rb:49:in each' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/initializable.rb:49:inrun_initializers' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/application.rb:134:in initialize!' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/application.rb:77:insend' /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/application.rb:77:in method_missing' /Users/chietala/Desktop/rails_projects/sample_app/spec/../config/environment.rb:5 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' /Users/chietala/Desktop/rails_projects/sample_app/spec/spec_helper.rb:10 /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/bin/../lib/spork.rb:23:inprefork' /Users/chietala/Desktop/rails_projects/sample_app/spec/spec_helper.rb:4 /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/lib/spork/test_framework.rb:138:in load' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/lib/spork/test_framework.rb:138:inpreload' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/lib/spork/app_framework.rb:64:in preload' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/lib/spork/test_framework.rb:134:inpreload' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/bin/../lib/spork.rb:67:in exec_prefork' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/lib/spork/test_framework.rb:120:inpreload' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/lib/spork/run_strategy/forking.rb:25:in preload' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/bin/../lib/spork/runner.rb:74:inrun' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/bin/../lib/spork/runner.rb:9:in run' /usr/local/lib/ruby/gems/1.8/gems/spork-0.8.4/bin/spork:10 /usr/local/bin/spork:19:inload' /usr/local/bin/spork:19
Luckily I am using Git for version control and I was in a separate branch when I received this problem, however switching to the master still results in the error.
I'm not really sure where or how to fix this problem. Anyone have any ideas?

I was using 1.9.2, rails3, and rspec-rails 2.0.0rc with spork-0.8.4 successfully. Then I upgraded to rspec-rails 2.0.0 and had some issues.
I just upgraded my Gemfile to rspec-rails 2.0.1 and spork 0.9.0.rc2 and everything works again!
Gemfile:
gem 'rspec-rails','>= 2.0.1'
gem 'spork', '>= 0.9.0.rc2'
Give that a shot. (You can always switch back to your old version, if it doesn't help.)
Check the spork page on github to see if there are any other things to consider. If you are using 1.8.7 there may be some differences.
If you want the cutting edge (sometimes I do on gems):
gem 'spork', :git => 'http://github.com/timcharper/spork.git'
Maybe there is a fix for your particular combo....
Let me know if this helps!

Related

visit_Psych_Nodes_Alias: Unknown alias: default (Psych::BadAlias)

I updated from ruby 2.7.1 to 3.1.1, then removed Gemfile.lock and ran bundle update (it's on a dev branch, so I can throw it away if this is a bad idea, I just wanted to see if it would work).
bundle update succeeds, but when I start the server:
rails s
=> Booting Puma
=> Rails 7.0.2.2 application starting in development
=> Run `bin/rails server --help` for more startup options
Exiting
/Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:430:in `visit_Psych_Nodes_Alias': Unknown alias: default (Psych::BadAlias)
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:345:in `block in revive_hash'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each_slice'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `revive_hash'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:167:in `visit_Psych_Nodes_Mapping'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:345:in `block in revive_hash'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each_slice'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `revive_hash'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:167:in `visit_Psych_Nodes_Mapping'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:318:in `visit_Psych_Nodes_Document'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych.rb:335:in `safe_load'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/psych.rb:370:in `load'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:30:in `available_environments'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:21:in `current'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:15:in `inquire'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:7:in `inquire'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/instance.rb:11:in `env'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/instance.rb:18:in `config'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker.rb:34:in `config'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/railtie.rb:32:in `block in <class:Engine>'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:32:in `run'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:347:in `each'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:347:in `call'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/application.rb:372:in `initialize!'
from /Users/st/rails/hangswith/config/environment.rb:5:in `<main>'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:42:in `require_relative'
from config.ru:3:in `block in <main>'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:36:in `start'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:143:in `block in perform'
from <internal:kernel>:90:in `tap'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:134:in `perform'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/command/base.rb:87:in `perform'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/command.rb:48:in `invoke'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands.rb:18:in `<main>'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from /Users/st/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
from bin/rails:4:in `<main>'
What I've tried
Googling the 'psych' error message reveals this which may be related. But when I search the entire app for YAML.safe_load (or even just safe_load), there are 0 occurrences of it. (perhaps I should be searching actual gems in my app?).
It was a long shot but based on this comment, I ran gem rdoc --all to update all rdoc documentation. But that didn't help.
The problem is related to the Ruby 3.1 / Psych 4.x incompatibility described in this issue: https://bugs.ruby-lang.org/issues/17866
Ruby 3.0 comes with Psych 3, while Ruby 3.1 comes with Psych 4, which has a major breaking change (diff 3.3.2 → 4.0.0).
The new YAML loading methods (Psych 4) do not load aliases unless they get the aliases: true argument.
The old YAML loading methods (Psych 3) do not support the aliases keyword.
At this point, it seems like anyone, anywhere that wants to load YAML in the same way it worked prior to Ruby 3.1, need to do something like this:
begin
YAML.load(source, aliases: true, **options)
rescue ArgumentError
YAML.load(source, **options)
end
as patched by the Rails team.
In your case, I suspect you will need to see which Rails version that matches your major version preference includes this patch before you can upgrade to Ruby 3.1.
Personally, wherever I have control of the code that loads YAML, I am adding an extension like this:
module YAML
def self.properly_load_file(path)
YAML.load_file path, aliases: true
rescue ArgumentError
YAML.load_file path
end
end
or, if I want to completely revert this change done in Psych 4, I add this to my code:
module YAML
class << self
alias_method :load, :unsafe_load if YAML.respond_to? :unsafe_load
end
end
This has the advantage of restoring YAML::load, and YAML::load_file (which uses it) to their original glory, and solves everything including libraries that you have no control of, in all Ruby versions.
Lastly, as I mentioned in the comments, in case you prefer a minimally invasive stopgap measure, you might be able to get away with pinning Psych to < 4 in your Gemfile:
gem 'psych', '< 4'
Note for Rails users (>= 7.0.3.1)
ActiveRecord 7.0.3.1 changed an internal call and it now calls safe_load directly. If you see a Psych related error during rails tests, you might be affected by this change.
To resolve it, you can add this to a new or existing initializer:
# config/initializers/activerecord_yaml.rb
ActiveRecord.use_yaml_unsafe_load = true
You may also use ActiveRecord.yaml_column_permitted_classes to configure the allowed classes instead.
More info in this post.
I ran into the same problem, using a very recent version of rails and ruby 3.1.1 and the suggestion that DannyB mentioned fixed my problem.
In my Gemfile, I put webpacker3 and specified psych < 4. I don't know yet if this version of psych will break something down the road but at least webpacker installed:
gem 'webpacker', '~>3.0'
gem 'psych', '< 4'
In my case I had ruby version 3.0.3 on gem 'rails', '~> 6.1.5'
My default system version was locked to psych (default: 3.3.2) but somehow Gemfile.lock had stuff broken with:
psych (4.0.3)
stringio
sdoc (2.3.1)
rdoc (>= 5.0, < 6.4.0)
The solution was to remove those, then lock correct version of Psych in Gemfile
gem 'psych', '< 4
Then bundle install which fixed the circular broken dependencies
A simple solution: downgrade to ruby 3.0.X
This is simple and easy, requires no code changes, and can be upgraded to ruby 3.1.x in the near future when everything's caught up and is compatible with Psych 4.
Note: ruby 3.0.3 is the latest ruby version which still uses Psych 3.x.x, so there are no problems and everything just works.
Why this solution?
I prefer this option because patching an app or its gems can get complicated and I prefer the simplest/safest solution.
See here and here for the advice that helped me make the decision:
I think it's best to revert to ruby 3.0.3, so as to use the latest ruby version that doesn't use psych 4. Do you think that's a good idea?
Absolutely yes in regards to reverting to Ruby < 3.1 ... it takes time until the gem developers community will update their gems
Why not downgrade psych instead?
The only reason I didn't downgrade psych gem instead of ruby is because I'm not 100% sure that doing so won't cause problems elsewhere, potentially things that are hard to detect. Although it could be a completely viable solution (I'm just not sure that it is, hence I prefer to play it safe and downgrade ruby instead).
in my case, after update to ruby 3.1.2 updating to rails 7.0.4 solved it.

Rails commands not working (spring gem error)

I'm honestly so lost. Every time I try to run any rails commands ie, rails g controller home, the command line throws me this error and I have no idea what's going on. I've uninstalled and reinstalled spring and I've also googled.
Someone help please?
Johnny#Johnnys-MacBook-Pro original_skillup (feature/s3_uploader) $ rails g controller spring
/Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `block in preload': undefined method `[]' for nil:NilClass (NoMethodError)
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `map'
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `rescue in preload'
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:115:in `preload'
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/Johnny/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Johnny/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
Thanks!
I think you have Spring gem installed and the name of controller is conflicting.
https://github.com/rails/spring
Try changing the name of controller. Hopefully it works. Cheers!
To the previous answer, you can have a controller named home (there's no naming issues with that). It does look like you have an issue with the version of the spring gem you are using. Have you tried running 'bundle install'? I checked the spring gem on Github and it does not look like there are any current issues with the gem. You could remove the spring gem and see if the issue persists, if so, then you know the issue lies deeper.
That is Exception backrace issue in spring gem.
https://github.com/rails/spring/pull/459
update spring to 1.6.1

Libxml-ruby error on Rails app startup -- uninitialized constant LibXML::XML::Error::I18N

I just updated to Rails 3.2.12 and Bundler also updated libxml-ruby from 2.4.0 to 2.5.0. When I restart my production server (nginx), or try to open a console, I get:
/home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:10:in `const_get': uninitialized constant LibXML::XML::Error::I18N (NameError)
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:10:in `block (2 levels) in <class:Error>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:8:in `each'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:8:in `block in <class:Error>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:7:in `tap'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:7:in `<class:Error>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:5:in `<module:XML>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:4:in `<module:LibXML>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml/error.rb:3:in `<top (required)>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/libxml.rb:11:in `<top (required)>'
from /home/cceom/webapps/rails2/gems/gems/libxml-ruby-2.5.0/lib/xml.rb:13:in `<top (required)>'
I'm not having the same issue on my dev box.
All I can figure is that some how the 2.5.0 gem is still referencing the old 2.4.0 compiled libraries and that particular constant is not defined in them. But no idea how this would happen nor how to rectify it. Nor whether this is even correct.
Any thoughts would be welcome.
I had the same problem, it fails on production but works on local. I tried freezing the version of the gem libxml-ruby to 2.4.0 and it works like a charm.
Hope it helps!
The issue happened on older versions of libxml. I just released an updated version of libxml-ruby, 2.6.0, that should resolve the issue.

Rails, Devise, and Mongo - Which versions do I use?

I'm currently trying to get a Mongo database running alongside Devise. I'm using Rails 3.2.2 and Ruby 1.9.3, mongo_mapper 0.11.0, devise 1.1.9, and devise-mongo_mapper 0.0.2. I've referred to numerous sources online, but they seem to be invariably outdated.
A huge problem I'm facing right now involves devise-mongo_mapper. With mongod running on the terminal, trying to run the rails server gives me the following:
/usr/local/lib/ruby/gems/1.9.1/gems/devise-1.1.9/lib/devise.rb:193:in `mailer=': undefined method `ref' for ActiveSupport::Dependencies:Module (NoMethodError)
from /usr/local/lib/ruby/gems/1.9.1/gems/devise-1.1.9/lib/devise.rb:195:in `<module:Devise>'
from /usr/local/lib/ruby/gems/1.9.1/gems/devise-1.1.9/lib/devise.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /home/neilbasu/Desktop/rails_practice_app/onemoremongopractice/config/application.rb:13:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I checked online and found this could be because my devise isn't updated. Trying to update it gave me this:
Bundler could not find compatible versions for gem "devise":
In Gemfile:
devise-mongo_mapper (>= 0) ruby depends on
devise (~> 1.1.0) ruby
devise (2.0.4)
So basically, the older devise won't work, and the newest version isn't compatible with my current devise-mongo_mapper. Is there any way around this? Either a way to get all of these programs working together or a way to not need devise-mongo_mapper at all would be great.
Take a look at several of the forks.
They just bumped the version in the gemspec and the code probably works unchanged.
You can install whatever version of the gem you want using the -v argument.
sudo gem install whatever -v 1.0.1
Or you can look at the forks as Plastic Chicken suggested.
I was also facing the same error and running "bundle update" solved my problem.

Rails 3.2.0 rspec debugger not working

I've just upgraded to ruby 1.9.3-p0 and rails 3.2.0. I'm now trying to debug an error in one of my tests using
rspec spec -d
But I get this error:
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:422:in `rescue in debug=': (RuntimeError)
**************************************************
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type - /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so
If you have it installed as a ruby gem, then you need to either require
'rubygems' or configure the RUBYOPT environment variable with the value
'rubygems'.
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:408:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:408:in `debug='
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:19:in `block in configure'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `each'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `configure'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:21:in `run'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
**************************************************
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:407:in `debug='
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:19:in `block in configure'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `each'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `configure'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:21:in `run'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
Install the new debugger gem that works with Ruby 1.9.3 and 1.9.2:
https://github.com/cldwalker/debugger
Stick this in your Gemfile:
# one-liner to install these properly: bash < <(curl -L https://raw.github.com/gist/1333785)
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'
You'll need to run that one-liner in order for bundler to pick up the proper gems.
EDIT: I forgot to link to the posts I used to get debugging working:
ruby-debug with Ruby 1.9.3?
ruby-debug19 on ruby-1.9.3-preview1
I guess I can't comment on other answers yet, but I found many of these instructions don't mention you'll still need to include the
gem 'ruby-debug19', :require => 'ruby-debug'
line in your Gemfile, in addition to the instructions siannopollo provides. Without this, I get a 'cannot load such file -- ruby-debug' error (OSX, rvm, 1.9.3-p125).
FWIW, the gist is hardcoded to 1.9.3-p0, so if you're on 1.9.3-p125, you might need to edit it (also, generally a bad idea to execute a gist you haven't read).
For me, all it took was:
gem 'debugger'
in the Gemfile
Had to upgrade the following
bundle update ruby-debug-base19

Resources