All of the sudden, Rails' console stopped working on one of my projects. I keep getting the following error:
rails c
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Could not find activesupport-4.1.4 in any of the sources
Run `bundle install` to install missing gems.
So I updated Rubygems, with the following two lines (from rubygems.com)
$ gem install rubygems-update # again, might need to be admin/root
$ update_rubygems
and get the following output:
Successfully installed rubygems-update-2.4.4
Parsing documentation for rubygems-update-2.4.4
Done installing documentation for rubygems-update after 0 seconds
1 gem installed
...
RubyGems 2.4.4 installed
Parsing documentation for rubygems-2.4.4
Installing ri documentation for rubygems-2.4.4
=== 2.4.4 / 2014-11-12
Aaaaaand, then I run rails console again, and just get the same error message again.
Thoughts?
This might be the problem only if you use rvm else just ignore it.
Navigate to the root path (where your rails app is located).
type in your command line;
rvm list
You will get something like:
rvm rubies
jruby-1.7.11 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
=* ruby-2.0.0-p451 [ x86_64 ]
ruby-2.1.0 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
If your default is not the current you have most likely changed it.
Try to change it back and run:
You can change it like so:
rvm use ruby-2.0.0-p451
When you get the right version you can make it permanent.
like so:
rvm --default use ruby-2.0.0-p451
bundle install
again.
Just a shot in the dark, but maybe try:
gem install activesupport -v 4.1.4
Then try and run rails c again.
The message also says to run gem pristine --all which will reinstall all the gems from the cache and recompile all native drivers in the gems.
Updating the Rubygems code doesn't do this so you have to explicitly run the command.
Related
I had used ruby version manager (rvm) to install a new version of ruby. Running the command rvm rubiesshows all the version of rubies that are installed. The list is given below.
rvm rubies
ruby-1.9.3-p551 [ x86_64 ]
ruby-2.1.5 [ x86_64 ]
ruby-2.2.4 [ x86_64 ]
* ruby-2.3.0 [ x86_64 ]
ruby-2.3.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
I tried to run the command bundle exec rake rb:mgirate and I get the following error.
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'bundler' (>= 0.a) among 5 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=:/nix/.nix-profile/lib/ruby/gems', execute `gem env` for more information
The error states that bundler isn't installed. I ran the command gem install bundle and I get the following error.
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /nix/.nix-profile/lib/ruby/gems directory.
It says that I don't have write permissions. I googled the error and it has something to do with updating ruby and ruby version. The reason why I updated to a new ruby version was because heroku run rake db:seed wasn't seeding data in production. I though it might be due to compatibility issues. Therefore, I decided to update to the new version of ruby. The servers, postgresql and everything else works fine. I can't run bundle because I can't install the gem. Any hep would be greatly appreciated. Thanks!
The problem was fixed by switching to the ruby version 2.3.0 by running the command rvm user 2.3.0. Once that is done you should restart the workspace. The reason for the error was the fact that when you switch ruby version it also changes gem files. Therefore, it wasn't able to recognize the gems.
hey just add "sudo" at the beginning of your command. It will definitely work, because as the error says you don't have write permission. And if you will check the permission of that directory than you will find that only owner has write permission and as sudo takes us to the owner mode from user mode. Hence you will not get this error again. Please let me know if it doesn't works.
I'm having trouble understanding where this Gemfile referred to by the bundle install output is. My general project directory is /code and there is no Gemfile here, hidden or visible. I tried rvm implode to clear things out but the issue remains.
$ gem install rails
Successfully installed rails-4.2.5
Parsing documentation for rails-4.2.5
Done installing documentation for rails after 0 seconds
1 gem installed
$ rails new myapp --database=postgresql
Could not find proper version of railties (4.0.2) in any of the sources
Run `bundle install` to install missing gems.
$ rails -v
Could not find proper version of railties (4.0.2) in any of the sources
Run `bundle install` to install missing gems.
$ bundle install
Your Ruby version is 2.2.0, but your Gemfile specified 2.0.0
$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ rvm list
rvm rubies
=* ruby-2.2.0 [ x86_64 ]
ruby-2.2.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
It looks like you may have an issue with your global gemset. Try creating a new gemset for the app using rvm:
rvm use 2.2-head#myapp --create
From there install rails and see if all goes well.
I have latest RVM installed in OX 10.9.
$ rvm rubies
* ruby-1.9.3-p545 [ x86_64 ]
=> ruby-2.1.1 [ x86_64 ]
$ rvm gemset list
gemsets for ruby-2.1.1 (found in /Users/rajveershekhawat/.rvm/gems/ruby-2.1.1)
(default)
global
rails403
rails404
=> rails410
After this i installed rails.
$ gem install rails -v 4.1.0
It got installed. It is also there in correct location within .rvm folder. But when I try using it, system says rails is not installed.
$ rails -v
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I have tried it twice and still unable to figure out what am I am missing. Please help.
Thanks.
This question is similar but is not helping.
Edits:
$ gem list | grep rails
rails (4.1.0)
sprockets-rails (2.1.3)
$ echo $PATH
/Users/rajveershekhawat/.rvm/gems/ruby-2.1.1#rails410/bin:/Users/rajveershekhawat/.rvm/gems/ruby-2.1.1#global/bin:/Users/rajveershekhawat/.rvm/rubies/ruby-2.1.1/bin:/Users/rajveershekhawat/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Update:
Seems like the rails was not properly installed before. I recreated the gemset and tried to intall rails again but got some error. Then I again emptied the gemset and reinstalled rails with sudo. This resolved the issue.
Try to run:
rvm use ruby-2.1.1#rails410
gem list
Can you find Rails here?
Why did you call sudo gem install rails, cant be this the problem, you do not need to use sudo.
For a Rails app, I tried running $ bundle install. But, even after I ran $ gem install bundler, I got the same message.
this is what happened:
Run `bundle install` to install missing gems.
Davids-iMac-2:213calendar davidburton$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
Davids-iMac-2:213calendar davidburton$ gem install bundler
Successfully installed bundler-1.3.5
1 gem installed
Installing ri documentation for bundler-1.3.5...
Installing RDoc documentation for bundler-1.3.5...
Davids-iMac-2:213calendar davidburton$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
UPDATE1
rvm list
rvm rubies
ruby-1.9.2-p290 [ x86_64 ]
=* ruby-1.9.3-p374 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Check your home directory for a ~/.bash_profile file.
If it exists, and you don't remember creating it, copy its contents to ~/.bashrc and remove the .bash_profile file completely.
By default, rvm appends the commands for updating path with rvm function in .bash_profile after rvm installation.
Ubuntu, at a time only uses .bash_profile if it is present, or .bashrc when .bash_profile is absent. This results in PATH not being correctly set, and the gem, even though installed, is not detected since it is not on your path.
I installed jRuby using rvm. It's version is jruby-1.6.7.2 [ i386 ].
Now I am trying to install rails on top of it.
But I am getting following error
ERROR: Error installing rails: activesupport requires Ruby version >= 1.9.3.
I am using following command to install rails which I found in many answers on so itself.
jruby -S gem install rails --pre --no-rdoc --no-ri
I also tried passing --1.9 option to jruby so that it can use ruby 1.9 interpreter. But that also not working.
jruby --1.9.3 -S gem install rails
My RVM list is as follows :
rvm rubies
=> jruby-1.6.7.2 [ i386 ]
ruby-1.8.7-p358 [ i686 ]
* ruby-1.9.3-p194 [ i686 ]
ruby-1.9.3-p286 [ i686 ]
Please guide me whats going wrong?
Are you able to update your JRuby version?
Alternatively, try set this shell variable:
export JRUBY_OPTS=--1.9
...then re-execute your gem install rails command.