Ruby: “gem install bundler” not installing bundler

2019-02-18 18:59发布

问题:

I'm new to rails and trying to get a demo app up and running. I've been having problems on my linux system (lubuntu, mostly clean install) getting "bundle install" to run. Even when it does, if I close my terminal and start another, it fails to run again. The cycle looks something like this:

sandbox@75bf7f3:~/railsstuff/sample_app_2nd_ed$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.

sandbox@75bf7f3:~/railsstuff/sample_app_2nd_ed$ gem install bundler
Successfully installed bundler-1.1.4
1 gem installed

sandbox@75bf7f3:~/railsstuff/sample_app_2nd_ed$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.

As far as I can tell, I'm using the latest version of Ruby and rvm seems to be working fine.

Can anyone explain what's going on here?

回答1:

I can confirm this is happening in a fresh rvm install of Linux Mint. I'm using gnome-terminal and I have applied the "Run command as login shell" workaround. I'm using ruby 1.9.3 and haven't done anything with gemsets. When I type 'gem list' I see all the rubies I've installed (the first hour I got rvm installed, I playing around installing some projects and it seemed to be in perfect working order).

It looks like adding

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

to ~/.bashrc clears up the inconsistency problems. It's odd that it was working fine initially without it... And it should only be sourcing .bash_login in the first place...