cstingl
cstingl

Reputation: 603

RVM Bundle Install Missing Gem Error even though gem is installed

I'm getting the following error even though I currently do have the Bundler gem installed (it appears when I run $gem list).

ERROR: Gem bundler is not installed, run `gem install bundler` first.

I'm using RVM and my $PATH is as follows:

/Users/cjstingl/.rvm/gems/ruby-1.9.2-p290@rails3tutorial2ndEd/bin:
/Users/cjstingl/.rvm/gems/ruby-1.9.2-p290@global/bin:
/Users/cjstingl/.rvm/rubies/ruby-1.9.2-p290/bin:
/Users/cjstingl/.rvm/bin:
/Users/cjstingl/.bin:
/usr/local/sbin:
/usr/local/Cellar/php/5.3.6/bin:
/usr/local/share/python:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin

Also this is my gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.15
  - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.2.0]
  - INSTALLATION DIRECTORY: /Users/cjstingl/.rvm/gems/ruby-1.9.2-p290@rails3tutorial2ndEd
  - RUBY EXECUTABLE: /Users/cjstingl/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/cjstingl/.rvm/gems/ruby-1.9.2-p290@rails3tutorial2ndEd/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-11
  - GEM PATHS:
     - /Users/cjstingl/.rvm/gems/ruby-1.9.2-p290@rails3tutorial2ndEd
     - /Users/cjstingl/.rvm/gems/ruby-1.9.2-p290@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => false
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "-n/usr/local/bin --no-ri --no-rdoc --no-user-install"
  - REMOTE SOURCES:
     - http://rubygems.org/

Also: Using the bundle -v command returns the same error

I've tried imploding RVM and reinstalling which doesn't seem to work. I'm stumped and any help would be appreciated.

Upvotes: 55

Views: 33257

Answers (19)

MorningHacker
MorningHacker

Reputation: 1204

I had this problem, too. I fixed my issue by specifying a gemset.

$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.

$ rvm gemdir
/usr/local/rvm/gems/ruby-1.9.3-p194

$ rvm gemset list

gemsets for ruby-1.9.3-p194 (found in /usr/local/rvm/gems/ruby-1.9.3-p194)
   global
   rails32

$ rvm gemset use rails32

Using ruby-1.9.3-p194 with gemset rails32

$ rails s

Could not find rake-10.0.4 in any of the sources

Run `bundle install` to install missing gems.

$ bundle install

Fetching gem metadata from https://rubygems.org/.......
{And voila! it worked!}

Upvotes: 0

coneybeare
coneybeare

Reputation: 33101

For my setup, adding the user that apache runs as to the rvm group worked

usermod -a -G rvm www-data

Upvotes: 0

EastLake
EastLake

Reputation: 61

If you got to the bottom of this and are still banging your head against the wall...

My problem was that rvm install 1.8.7 failed late in the install but appeared to have been successful (I had ruby 1.8.7 and could create gemsets)

But it seems like $GEM_HOME is set late in the install script and since that wasn't set, rvm wasn't looking in the right spot for gems.

I ran rvm reinstall 1.8.7 and looked carefully for errors.

What tipped me off was this thread: https://groups.google.com/d/topic/rubyversionmanager/aUBDxbBzZpE/discussion

You can check to see if this is your problem by running

echo $GEM_HOME or gem env or checking your rvm install log (see link above)

Do you see your ruby version and gemset name in your Gem Path? If not, maybe the rvm install failed.

Upvotes: 6

Jeff
Jeff

Reputation: 109

Ran into the same issue (where I kept on installing the bundler and rvm won't recognize it) on one of my laptops. I guessed I might have installed RVM wrong while I was still a rails noob. I tried the solution above but it didn't work for me. After messing around with it, I gave up and removed RVM and reinstall it. I figured it was due to some weird configuration issue deeply nested somewhere or . Here are the steps I took:

Remove RVM:

rvm implode

Install RVM again:

curl -L https://get.rvm.io | bash -s stable --rails
rvm reload

Since I am working on an old rails project for work, I had to install ree-1.8.7-2012.02

rvm install ree-1.8.7-2012.02

Of course, Murphy's Law still applies. I ran into another issue where my laptop could not find a Non-broken C compiler even though Xcode is installed along with gcc. My final steps were going to https://github.com/kennethreitz/osx-gcc-installer and install their package and reinstalling ree.

I hope this last resort solution helps someone. Good luck!

Upvotes: 0

mArtinko5MB
mArtinko5MB

Reputation: 788

Try this : https://rvm.io/integration/gnome-terminal/

it says about profiles run on startup, i am running ubuntu 12.10 and it work. Only thing you have to do is set "Run command as a login shell" in terminal profile preferences (tab title and command).

Hope it saves some time to someone.

Upvotes: 4

Koen.
Koen.

Reputation: 26949

After having RVM installed on multiple machines with the same setup and having problems with RVM on one but not having these problems on another one, I decided to look for something better, less error prone.

I found and switched to rbenv, which is much more simplistic than RVM.

And as the README of rbenv states:

rbenv does…

  • Let you change the global Ruby version on a per-user basis.
  • Provide support for per-project Ruby versions.
  • Allow you to override the Ruby version with an environment variable.

In contrast with rvm, rbenv does not…

  • Need to be loaded into your shell. Instead, rbenv's shim approach works by adding a directory to your $PATH.
  • Override shell commands like cd. That's dangerous and error-prone.
  • Have a configuration file. There's nothing to configure except which version of Ruby you want to use.
  • Install Ruby. You can build and install Ruby yourself, or use ruby-build to automate the process.
  • Manage gemsets. Bundler is a better way to manage application dependencies. If you have projects that are not yet using Bundler you can install the rbenv-gemset plugin.
  • Require changes to Ruby libraries for compatibility. The simplicity of rbenv means as long as it's in your $PATH, nothing else needs to know about it.
  • Prompt you with warnings when you switch to a project. Instead of executing arbitrary code, rbenv reads just the version name from each project. There's nothing to "trust."

So if you ask me, dump RVM and switch to rbenv.

Upvotes: 3

lobati
lobati

Reputation: 10215

Ran into this problem myself after updating my Ruby patch level. I ran which gem and discovered that it was using a global version of rubygems, in this case the path was ~/.rvm/bin/gem. So I ran rvm rubygems current, which installed it in ~/.rvm/rubies/ruby-1.8.7-p370/bin/gem. Ran gem install bundler and bundle again. Problem solved.

Upvotes: 1

gordonbanderson
gordonbanderson

Reputation: 261

I ran into the same problem earlier today. The approach I used to resolve the issue was this:

1) Run

cap shell

on the same machine you would normally run cap deploy. Then execute

env | sort

This runs the command on the remote server. Copy and paste the output into a local text file, e.g. capenv.txt

2) SSH into the same remote server, and do the same command, namely env | sort. Save this locally as a text file, e.g. sshenv.txt

3) Diff the two files and see what is in sshenv.txt that is not in capenv.txt - this is most likely where your problem lies.

< ++CAP ++
< _=/bin/sh
---
> ++ SSH ++
> __array_start=0
14a15
> PS1=\[\e]2;tracker@charlotte\a\e[0;31m LIVE:\u@\h \w> \e[0m
18d18
< rvm_env_string=ruby-1.9.3-p194
21d20
< rvm_ruby_string=ruby-1.9.3-p194
27c26,28
< USER=tracker
\ No newline at end of file
---
> USER=tracker
> USES_BASHRC=bashrc
> _=/usr/bin/env

4) I immediately noticed that the shell interpreter was not set to bash. This can be fixed by adding

set :shell, '/usr/bin/bash'

to your deploy.rb file. This resolved my problem

Upvotes: 2

Lasse Skindstad Ebert
Lasse Skindstad Ebert

Reputation: 3390

I had a similar issue. It turned out I didn't have a project specific .rvmrc file. I just created it using

rvm --rvmrc --create 1.9.3@my_project_name

In my project dir

This solved the issue

Upvotes: 7

mloughran
mloughran

Reputation: 11804

I had the same issue when I had an empty .rvmrc file in the directory I switched to (rvm 1.15.1). Obviously there are lots of causes for this error

Upvotes: 0

Rick Fletcher
Rick Fletcher

Reputation: 538

I had the same problem with a clean install of RVM 1.10.3. After reinstalling I noticed that bundler is installed, and that <gemset>/bin directories are being added to my $PATH, but those bin directories don't actually exist. I think it's just an RVM bug.

As a quick fix I manually copied the bundle binary into an RVM bin dir that does exist. That seems to have fixed my problem:

$ cd ~/.rvm
$ cp gems/ruby-1.9.3-p0/gems/bundler-1.0.21/bin/bundle rubies/ruby-1.9.3-p0/bin/

The Ruby and Bundler versions in those paths will likely be different for you.


The solution above works however it was bugging me so I put it to the rvm guys; it turns out my ~/.gemrc file was overriding the gem location with this line:

- "gem" => "-n/usr/local/bin"

Removing it fixed it for me. See here for full thread: https://github.com/wayneeseguin/rvm/issues/1043#issuecomment-7336267

Upvotes: 19

Patrick Smith
Patrick Smith

Reputation: 772

I had a similar problem, and the answer (at least for me) was maddeningly simple after lots of trial and error.

This is definitely a path issue, and @gamecreature's mentioning of path order was the crucial clue for me.

I'm not sure how it happened, but I had $HOME/.rvm/bin as the first item in my PATH export.

This is unnecessary as this directory gets added to the path in the correct order through sourcing the rvm file.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

So my fix was just to remove $HOME/.rvm/bin from my PATH export.

If you have multiple init files (.bashrc, .bash_profile, .profile), make sure to follow the advice on the rvm troubleshooting page:

make sure that the sourcing of the rvm file occurs last in your profile files (.bash_profile / .bashrc / .zshrc) essentially after any customizations of PATH / functions or aliases.

But I'd also recommend checking the rest of your PATH definition to make sure there aren't any duplicates declared that would take precedence.

Upvotes: 10

Daniel James
Daniel James

Reputation: 3939

I had a very similar problem for a slightly different reason. My home directory had a .gemrc file left over from an old ruby setup, and I'd missed when deleting the old files. It seems that gem was confusing the rvm settings with the settings in this file. Once I removed it (and some files installed to the old location), everything worked fine.

Upvotes: 2

user1417226
user1417226

Reputation: 21

I installed ruby 1.9.3 by rvm. After git octopress completed, just edit $path_of_git/.rvmrc like this "rvm use 1.9.3". AND THEN run command of "cd ..; cd $path_of_git". After that it will ask you weather trust the .rvmrc or not. Type 'y' to make .rvmrc file work.

Upvotes: 2

Erik Shilts
Erik Shilts

Reputation: 4509

This works for me when I specify the version of Ruby I want to use:

$ rvm use 1.9.2-p290
Using /Users/myname/.rvm/gems/ruby-1.9.2-p290

Upvotes: 1

Minqi Pan
Minqi Pan

Reputation: 2801

You know what, this is obviously your PATH variable's problem.

You should make sure that which bundle to be like /usr/local/rvm/gems/ruby-1.9.3-p194/bin/bundle instead of something like /usr/local/rvm/bin/bundle.

hint:

Did you just use PATH=some explicit list in your .zshrc file?

Then you should change that to PATH=$PATH:some list

Upvotes: 3

Matt Mitchell
Matt Mitchell

Reputation: 109

This happened to me as well after switching to a new empty gemset and running gem install bundler. The cause is that the shell is "remembering" the last bundle executable you used. To fix that (at least in bash-descendants):

hash -r

Upvotes: 3

Roman
Roman

Reputation: 13058

Adding the following (taken from .bash_profile) to .bashrc fixed it for me:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

Upvotes: 94

gamecreature
gamecreature

Reputation: 3282

I don't know if it's the cause of your problem. But I had a similar problem. The reason was that my RVM environment wasn't correctly.

I had 2 users, one which was working one that didn't. The working user used the following bundle script. (output from: which bundle)

/home/rvm/.rvm/gems/ruby-1.9.3-p0/bin/bundle

The wrong rvm-installation user used:

/home/user/.rvm/bin/bundle

The reason for this is the wrong $PATH order. The .rvm/gems/ruby-.../bin path should be placed before the ./rvm/bin path.

In my situation the cause was I set the $PATH variable to a rvm of another user. I fixed the issue by adding a symbolic link to the RVM of the user and changing my path from:

/home/rvm/.rvm/bin

to

/home/user/.rvm/bin

When the code above does not work for you, you can manually adjust the path just AFTER loading rvm.

Upvotes: 4

Related Questions