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
Related
I have just cloned a github repo https://github.com/maxitron93/p2pcollective.com, as i was exploring this awesome p2p lending app i encountered an error
NoMethodError: undefined method `alias_method_chain' for ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class
both when migrationg db or raunning server. I'm using the cloud9 ide to avoid my pc environment.
Running through a couple of solution posts, i updated my gem store with device and erubis but still returned back to that 'alias_method_chain' error.
Here's a snippet of my logs:
rake db:migrate
rake aborted!
NoMethodError: undefined method `alias_method_chain' for ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class
Did you mean? alias_method
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:80:in `<class:PostgreSQLColumn>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:74:in `<module:ConnectionAdapters>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:70:in `<module:ActiveRecord>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:2:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:256:in `block in load_dependency'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:662:in `new_constants_in'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:256:in `load_dependency'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/railties.rb:18:in `block (2 levels) in <class:Hstore>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
I expect my rails server to run smoothly from here.
alias_method_chain was deprecated and removed in Rails 5, but existed prior to that. It looks like a dependency (possibly pg) that has been installed is incompatible. You may be able to resolve the issue with bundle update pg, and if not, a broader bundle update should do the trick.
EDIT:
This is what I get for internet'ing before coffee. The gem responsible is in your stacktrace: activerecord-postgres-hstore, which isn't in the project you linked to, which suggests you've made other changes. You don't need that gem for Rails 4+. More info here
In my case, I had gem 'foreigner package from Gemfile
gem uninstall foreigner
bundle install
rails db:migrate
I hope it will be helpfull
I am trying to learn rails by following the tutorial here. However when I got to the section on creating the model and ran this command:
bin/rails generate model Article title:string text:text
I got this error:
/usr/lib/ruby/vendor_ruby/spring/application.rb:152:in `serve': undefined method `cleanup!' for ActionDispatch::Reloader:Class (NoMethodError)
from /usr/lib/ruby/vendor_ruby/spring/application.rb:131:in `block in run'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:125:in `loop'
from /usr/lib/ruby/vendor_ruby/spring/application.rb:125:in `run'
from /usr/lib/ruby/vendor_ruby/spring/application/boot.rb:18:in `<top (required)>'
from /usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
This is my second go through so I know I have followed all the steps. Any idea where I might look for the solution or know what the solution is?
This really has me stuck.
Versions:
Ubuntu 16.04
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
gem 2.6.12
rails 5.1.0
Based on this issue, can you run spring stop and try to run your command again?
Restarting worked for me too, but I needed to do it every-time. Instead, I upgraded to to the latest version of spring (2.0.2) in my gemfile. This fixed it.
I have ruby on rails installed and something kinda went fubar on it. When I try to generate a controller, I get the following:
➜ librius rails generate controller Teachers
Running via Spring preloader in process 27015
/Users/erick/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:287:in `load': no implicit conversion of nil into String (TypeError)
from /Users/erick/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/erick/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/erick/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:287:in `load'
from /Users/erick/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/erick/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
➜ librius
I've tried to uninstall/reinstall using gem and RVM but nothing seems to work.
Thanks.
The comments helped point in the right direction.
I did a gem upgrade (which I had to download because it kept telling me I had the latest). Then I did gem pristine --all, then spring stop. (Still wasn't working.) Then lastly, bundle install and voila! Such a hassle! Thanks!
After finishing the official getting started guide for RoR I played with it so much that I ruined the blog so I decided just to scrap everything and start again.
Now that I'm trying to run the rails server I get this error
/home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:109:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:109:in `destination_root='
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:85:in `initialize'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/cli.rb:17:in `initialize'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor.rb:359:in `new'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor.rb:359:in `dispatch'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/base.rb:440:in `start'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/cli.rb:10:in `start'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/bin/bundle:20:in `block in <top (required)>'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/bin/bundle:20:in `<top (required)>'
from /home/nadia/.gem/ruby/2.0.0/bin/bundle:23:in `load'
from /home/nadia/.gem/ruby/2.0.0/bin/bundle:23:in `<main>'
in the gemfile I have added
gem 'railties', '~>4.0.2'
then
$ bundle install
to try and resolve the issue. However it still hasn't work. I'm fairly new so I'm not actually sure what the error is.
Any thoughts would be appreciated.
I'm also running rails v4.0.2 if that helps
This is a pretty weird thing to see:
No such file or directory - getcwd (Errno::ENOENT)
Are you trying to run this application from a directory you maybe moved, or even deleted? That error implies that it can't determine the current directory.
Define rails in gem file like this
gem 'rails', '4.0.2'
And then bundle install.
Whoops. I derped. All sorted now. I was simply trying to run it from the wrong directory.
Should have seen it earlier.
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.