6

When i try to do bundle install, my gem_path and gem_home point to /usr/local/rvm/gems/ which i don't have write access and it fails because of invalid permissions. because of this i've changed both paths to a local directory where i do have write access.

when doing so, i do a bundle install, i get :

bruno@test6:~$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..

Bundler::GemspecError: Could not read gem at   /afs/varda.io/user/b/br/bruno/test6/cache/rake-10.1.0.gem. It may be corrupted.
An error occurred while installing rake (10.1.0), and Bundler cannot continue.
Make sure that `gem install rake -v '10.1.0'` succeeds before bundling.

well, if i do a gem install, it works just fine.

but bundle would just not work; even if a try to delete the cache folder that it complains about.

i did try "bundle install --no-cache" and it fails in the same way. (bundle install --deployment works fine too) how do i get bundle install to work ?

i've spent quite a bit of time, if anyone would have any guidance , i would really appreciate it!

elcomputerguy
  • 151
  • 1
  • 3
  • 9
  • what if you try `GEM_HOME=/path/you/can/write/to bundle install` ? – Anko Sep 09 '13 at 01:32
  • thanks Anko. I've already donde that ; the outcome is the same. – elcomputerguy Sep 09 '13 at 04:54
  • 3
    Are you on a unix system? I find the strace tool useful. `strace bundle install` will show you all the system calls which will tell you which files are trying to be opened and where it's failing. – Anko Sep 09 '13 at 07:10
  • are you an admin? why don't you give yourself write access to `/usr/local`? – David West Sep 12 '13 at 20:54

5 Answers5

19

Fixed it by deleting cache file and re-running bundle install.

rm -rf <location_of_cache>. In your case:

rm -rf /afs/varda.io/user/b/br/bruno/test6/cache
John Källén
  • 7,551
  • 31
  • 64
Oleg Rogov
  • 720
  • 3
  • 16
  • `mv /.gem ~/.Trash/` works well, and provides a fallback option in Trash in case you mess something up. – Magne Apr 02 '15 at 10:33
16

okay, first of all, you could solve all this issues easily by using rvm (user installation), see http://rvm.io, if that is not an option, you could try using project-specific gem paths. for example i have the following bundler config file (~/.bundle/config)

---
BUNDLE_PATH: .bundle
BUNDLE_DISABLE_SHARED_GEMS: "1"

which causes bundler to install all gems in a .bundle sub directory (inside your project folder, where you run bundle install). now, if you remember to use bundle exec for your bins (e.g. cap(istrano)), you're fine.

if you somehow f*cked up your bundler / cache, try deleting the .bundle folder (in your project folder)

Marian Theisen
  • 6,100
  • 29
  • 39
  • Thanks a lot Marian, actually rvm was causing a conflict. i was using rvm, but not to install individual gems, i re-imaged my ubuntu box,and installed rails without rvm, the problem was gone. – elcomputerguy Sep 24 '13 at 20:50
  • Thanks Marian, this worked for me and helped me understand what it was doing. Instead of installing the gems in a `.bundle` sub directory, I put them in a tmp folder. `--- BUNDLE_PATH: "/tmp/project-bundle" BUNDLE_DISABLE_SHARED_GEMS: '1' ` – Chnikki Sep 19 '17 at 15:41
1

rvm reinstall all worked for me.

Before you do that, I would try

gem update --system
gem pristine --all --no-extensions

please note that rvm reinstall all takes a lot of time to complete...

David West
  • 2,256
  • 6
  • 32
  • 62
1

If it's feasible, I recommend installing your own copy of rvm in ~/.rvm so you aren't tied to the system one. Trying to have a hybrid system+user approach will likely lead to more headaches later on.

Or, if you're open to alternate solutions, rbenv is a leaner & cleaner ruby manager.

Kelvin
  • 20,119
  • 3
  • 60
  • 68
  • what kind of headaches might it lead to? – David West Sep 12 '13 at 20:52
  • Like constantly needing to set `GEM_HOME` (and possibly rearranging the ordering in `GEM_PATH`), trying to understand the `gem` flags like `--user-install`, having to add yet another directory to your `$PATH` if you want to easily run executables. The bottom line is that rvm already does crazy things with your environment variables, and it might even stop working if you upgrade rvm. – Kelvin Sep 12 '13 at 21:36
  • And furthermore, if you try to run `GEM_HOME`-sensitive commands via Capistrano, cron jobs, daemons, or even ruby's `system` method, you're going to start wanting to shoot yourself. You'll go mad trying to remember when and how to pass environment variables. – Kelvin Sep 12 '13 at 21:48
0

Try to tell to bundler which folder it must use, something like bundle install --path <myfolder> or bundle install --path gems.

Note that I didn't test this yet, but it seems promising, please post the result for us.

Miguelgraz
  • 4,376
  • 1
  • 21
  • 16