RVM Bundle Install Missing Gem Error even though g

2019-01-30 05:59发布

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.

19条回答
做自己的国王
2楼-- · 2019-01-30 06:29

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.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-01-30 06:32

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!

查看更多
Luminary・发光体
4楼-- · 2019-01-30 06:36

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

查看更多
The star\"
5楼-- · 2019-01-30 06:36

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!}
查看更多
小情绪 Triste *
6楼-- · 2019-01-30 06:39

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

查看更多
叼着烟拽天下
7楼-- · 2019-01-30 06:40

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.

查看更多
登录 后发表回答