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.
Related
Please see below the print out from gem env. It appears as the INSTALLATION DIRECTORY, USER INSTALLATION DIRECTORY and GEM PATHS are screwed up. I attempted to install ruby version 2.3.0 for another project and switch over to that. I uninstalled ruby version 2.3.0 and switch back to ruby version 2.3.1. I noticed these RubyGems environment variables got screwed up some how :( Everywhere you see '2.3.0', I think it's wrong.
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/matthewsmith/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/matthewsmith/.rbenv/versions/2.3.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/bin
- SPEC CACHE DIRECTORY: /Users/matthewsmith/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- /Users/matthewsmith/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/matthewsmith/.rbenv/versions/2.3.1/bin
- /Users/matthewsmith/.rbenv/libexec
- /Users/matthewsmith/.rbenv/plugins/ruby-build/bin
- /Users/matthewsmith/.nvm/versions/node/v4.5.0/bin
- /Users/matthewsmith/.rbenv/shims
- /Users/matthewsmith/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
if there are multiple versions installed, project dependent version must be set as default.
To handle multiple projects with different dependencies, gemset can be used. RVM support gemset. Alternatives are available for rbenv also.
Nothing is wrong. I can see that you are using rbenv, and that your global ruby version is 2.3.1
If you run in your terminal:
gem env home
It will return something like:
/Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
Apparently this line of code above tells that you have global rbenv version 2.3.1, and within li/ruby/gems folder you also have installed ruby version 2.3.0
In this folder .rbenv/versions/ will be all ruby versions you will about to install, or they are already installed.
When I install different ruby version let's say 2.3.0 I would do like this:
rbenv install 2.3.0 # install ruby version 2.3.0 using rbenv
rbenv local 2.3.0 # set ruby 2.3.0 to local project. It writes that version to a .ruby-version in your current directory
ruby -v # check your version to confirm that is 2.3.0 for a local project
gem install bundler
bundle install
Other options for installing ruby version are: SHELL and GLOBAL
rbenv shell 2.3.0 # Will temporarily change your Ruby version on your current shell. This sets the RBENV_VERSION environment variable in your terminal session.
rbenv global 2.3.1 # This will also change your Ruby version, but only the one you are using whenever no other version is specified, e.g. via a .ruby-version file or RBENV_VERSION variable.
NOTE! You don't need sudo to install gems. Typically, the Ruby versions will be installed and writeable by your user. No extra privileges are required to install gems.
reference
I hope it helps
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.
I'm stumped on a problem that others on SO and around the web have been having, but whose answers don't seem to be working for me.
Trying to use the curb-fu gem, which a wrapper around the curb gem. Here's what I've tried:
gem list shows that curb and curb-fu are installed
i've added: gem 'curb' and gem 'curb-fu' to my Gemfile and run bundle install
i've uninstalled the gem files and tried restarting
i've uninstalled libcurl3, libcurl3-gnutls, and libcurl4-openssl-dev
load up a rails console, require curb-fu, and i can create an instance of CurbFu
load up irb, require curb-fu, and i can create an instance of CurbFu
In my app, at the top of my file, I:
require 'rubygems'
require 'curb-fu'
And I get: no such file to load -- curb-fu
What the heck am I doing wrong? The only thing I can think of is that curb-fu has a dependency on curb, which, according to it's github page, has only been tested on GNU/Linux x86. I'm running Ubuntu Linux x86-64. I doubt that's it, but just wanted to bring it up.
Any ideas?
Update:
I ran:
sudo find / -name "rubygems" -print
and the output was:
/root/rubygems-1.7.2/test/rubygems
/root/rubygems-1.7.2/test/rubygems/rubygems
/root/rubygems-1.7.2/lib/rubygems
/usr/share/doc/rubygems
/usr/local/lib/site_ruby/1.8/rubygems
/usr/lib/ruby/1.8/rubygems
Could that be the issue?
Update 2
Based off of this SO question I checked 'Gem.path' and 'gem env' and they're both pointing to the same place:
irb(main):003:0> Gem.path
=> ["/home/kf/.gem/ruby/1.8", "/usr/lib/ruby/gems/1.8"]
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.7.2
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/kf/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Restarted the server, and everything works. Only other thing I tried before that was updating my path to include my main gem path, /usr/lib/ruby/gems/1.8. This solution feels awful, but hey, I'm up and running.
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.
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"