When I tries to install rails:
root#li44-48:/# gem install rails
Successfully installed rails-3.2.1
1 gem installed
Installing ri documentation for rails-3.2.1...
Installing RDoc documentation for rails-3.2.1...
But when I do:
root#li44-48:/# rails
-bash: rails: command not found
I checked gem env and it displays:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Also the folder root#li44-48:/usr/lib/ruby/gems/1.9.1/gems/rails-3.2.1# is empty.
Any ideas on how to fix this?
I had the same issue after switching to an older version of Rails (3.2.16) from 4.0.2.
In my case it looks like railties need to be uninstalled as well - not just the rails gem.
Here's what I've done:
gem uninstall rails # choose to remove all
gem uninstall railties # choose to remove all
gem install rails -v 3.2.16
This happened to me after I uninstalled an old version of rails, and it asked me if I wanted to remove the binary too (which I did).
The newer rails binary is hidden under
/var/lib/gems/1.9.1/gems/railties-3.2.13/bin/rails
(on Ubuntu)
So I just created the symlink (not sure if this has negative side affects but it seems to work):
sudo ln -s /var/lib/gems/1.9.1/gems/railties-3.2.13/bin/rails /usr/local/bin
In an effort of rage quit, I:
removed ruby
removed gem
and recompiled both from source, and now gem install rails is fully working again.
I had the same issue and ended up using the RVM installer. This post http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/ shows you how and why use this tool.
check that rvm is a function type rvm | head -1
Try installing with:
sudo gem install rails
If you are running RVM you may not have it configured properly.
Related
I have a similar problem to: Invalid spec cache file
but it does not have an answer.
Our rails app recently upgraded from ruby 2.1.2 to 2.1.5
When I downloaded this onto my laptop (desktop working fine) it required be to rvm install 2.1.5, then create a new gemset for 2.1.5
I tried to run bundle and bundler isn't installed so I tried gem install bundler and it responded with the following error message:
ERROR: While executing gem ... (Gem::Exception)
Invalid spec cache file in /my_dir/.gem/specs/api.rubygems.org%443/latest_specs.4.8
On checking that directory, I find that there is a specs.4.8 file but not a latest_specs.4.8 file
Things I tried:
I deleted and re-created the gemset, same problem.
I ran gem update
I blew away /my_dir/.gem/specs and reran gem update
I ran gem update --system
I reinstalled ruby 2.1.5 and did it all again...
When I changed the ruby-version back to 2.1.2 and used rvm use 2.1.2; bundle it didn't have a problem (but then bundler already exists in that gemset).
Gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-darwin10.0]
- INSTALLATION DIRECTORY: /my_dir/.rvm/gems/ruby-2.1.5
- RUBY EXECUTABLE: /my_dir/.rvm/rubies/ruby-2.1.5/bin/ruby
- EXECUTABLE DIRECTORY: /my_dir/.rvm/gems/ruby-2.1.5/bin
- SPEC CACHE DIRECTORY: /my_dor/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /my_dir/.rvm/gems/ruby-2.1.5
- /my_dir/.rvm/gems/ruby-2.1.5#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Try this:
gem sources --clear-all
gem sources --update
If that doesn't work, see my longer answer here: Corrupted ruby gem system
Eventually I gave up and reinstalled ruby 2.1.5 and deleted the gemset.
Then it turned out I could install without bothering to first create a gemset.
Just rvm use 2.1.5 then gem install bundler then bundle
So: no idea what went wrong (and would still encourage others to answer for an explanation), but this is what worked for me.
Having some real difficulty setting up my RoR envirionment in Ubuntu 10.10
Installed RVM with ruby 1.9.2
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
and i have ruby gems setup
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
- INSTALLATION DIRECTORY: /home/toast/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /home/toast/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /home/toast/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/toast/.rvm/gems/ruby-1.9.2-p180
- /home/toast/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Now when it came to installing Rails i had all sorts of difficulties but now it seems to install:
$ sudo gem install rails
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
Installing RDoc documentation for rails-3.0.7...
yet rails commands fail and rails -v results in
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I'm out of ideas on this one!
many thanks
You've installed Rails under root user (sudo), and then you are trying to use it under local user. As far as it installed to root user you haven't got rails command in your local user PATH.
What you can do
Add its Path manualy
Install it via local user
Use RVM
I prefer to use RVM.
As far as you are using RVM, you don't need to use sudo. But when you need it you can use rvmsudo, but not in this case. Just
gem install rails
You don't have to use sudo with RVM.
If you type rvm info, you will see what ruby you use and where are your gems stored.
With sudo, you are probably using system's ruby from Ubuntu package.
Jus try gem install rails.
As others have said you need to install rails from gem via
gem install rails
The other somewhat tricky thing is that when you change into the rails app directory you need to make sure the dependencies are met for that app by doing:
bundle install
I've gone into a bit more detail on getting Rails 3 set up under Ubuntu at http://blog.dcxn.com/2011/06/21/rolling-with-rails-3-on-ubuntu-11-04/
Good luck!
Whether I use gem install or bundle install for my gems, they don't work. Sometimes sudo gem install gets gems to work. I ran the gem list -d and which gem commands, and it seems that my system is configured such that all the gems get installed into " /Library/Ruby/Gems/1.8" but my environment expects them in "/usr/bin/gem". How could I properly correct this? I was under the impression that 'bundle' should be able to install a local, application specific copy of a gem?
Although many Rubyists will recommend you RVM or RBENV, I do not use it. It's VERY slow and it pollutes your environment.
If you use Bundler, you dont need RVM at all - rubygem itself supports multiple versions of single gems. So you can just start using gems (e.g. gem install etc) and it will install into your $HOME/.gem directory by default. You can check the installation path using:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/lzap/.gem/ruby/1.9.3
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /home/lzap/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/lzap/.gem/ruby/1.9.3
- /usr/share/gems
- /usr/local/share/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- http://rubygems.org/
You can even change this with GEM_HOME environment variable. Happy gemming!
I would suggest using RVM (Ruby Version Manager) to control which version of Ruby you are installing your gems into. It will also help keep all the bundle and gem data in a folder in your home directory.
So this happens to me regularly, where i have gems that are installed but for some reason my rails app is not finding it...here is my example
my config/environment.rb
config.gem "whenever"
my install
sudo gem install whenever
Password:
Successfully installed whenever-0.6.2
1 gem installed
gem list | grep when
whenever (0.6.2)
script/server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
Missing these required gems:
whenever
You're running:
ruby 1.8.7.174 at /usr/local/bin/ruby
rubygems 1.3.7 at /Users/matt/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.4.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.8
- /Users/matt/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- http://gemcutter.org
$ which gem
/usr/local/bin/gem
$ which ruby
/usr/local/bin/ruby
Does anybody see the issue because i clearly cant even start my server and i know the gem is installed. I am on a macbook pro with Snow leopard by the way...
Please check you ruby and gem installation :
May be use these commands
which ruby
which gem
and make sure they have the correct path.
Most times people have these problems is that "gem" command installs gems into a different ruby installation instead of the one used by your rails app.
I had two different 1.9.x ruby versions, and I had installed rvm.
All the gems installed through rvm were not showing up.
Basically my "which gem" was showing /usr/bin/gem while it was supposed to be "/home/gh/.rvm/rubies/ruby-1.9.x/bin/gem"
If such is the case, in your gnome-terminal, under Edit > Profile Preferences > Title and Command, check the option "Run command as a login shell"
This integrates rvm with gnome-terminal :) Hope this helps someone who faced the same issue as I did.
Reference: https://rvm.io/integration/gnome-terminal
When trying to install Bundler 0.8.1 on Ubuntu machine, it install fine but the executable "bundle" is no where to be seen. Other gems install successfully, including their executables.
using: gem install bundler --version=0.8.1
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
- INSTALLATION DIRECTORY: /home/ahammad/gems
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /home/ahammad/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/ahammad/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gem1.gilt.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Path /home/ahammad/gems/bin has been added to PATH, the problem is there is no bundle exe.
Any ideas?
Maybe that specific version of bundler wasn't available for installation, so to choose specific available range of versions which could be available, try:
gem install bundler --version '<= 0.10.6'
Or simple uninstall the previous bundler and install it again. Then check by gem list bundler or bundler _0.9.26_ -v (where 0.9.26 is version of your older gem).
Check also the permissions of your local gem folders.
Learn more: How to upgrade/downgrade Rubygems at rubyforge
That might be. I've used only 1.0. But I had the same problem. A tutorial assumed I could run "bundle". It was fixed only after following the directions here
http://lindsaar.net/2010/3/31/bundle_me_some_sanity
The directions involve installing rvm and creating an app directory with a .rvmrc file among other things.
Then in that directory you can run "bundle".
The binary is ~/.rvm/gems/ruby-1.8.7-p302#railsplugins/bin/bundle
apparently 0.8.1 uses "gem bundle" rather than "bundle"