我开始处理一个新项目,它基于 ruby 1.8.7,我使用 rvm 来管理我的 ruby 版本,并且我已经安装了 1.8.7 和 1.9.2。
事情是当我这样做时:
rvm use 1.8.7
并尝试运行:
bundle install
我得到:
ERROR: Gem bundler is not installed, run `gem install bundler` first.
我已经安装了 bundler 5 次,即使之后它也说它没有安装。什么会导致这种情况? bundle 甚至出现在我的 gem 列表中。
评论更新:
which ruby && which gem 的输出是:
/home/username/.rvm/rubies/ruby-1.8.7-p371/bin/ruby
/home/username/.rvm/bin/gem
“env | grep -iE 'ruby|rvm|gem' | sort”的输出:
GEM_HOME=/home/username/.rvm/gems/ruby-1.8.7-p371@global
GEM_PATH=/home/username/.rvm/gems/ruby-1.8.7-p371@global
IRBRC=/home/username/.rvm/rubies/ruby-1.8.7-p371/.irbrc
MY_RUBY_HOME=/home/username/.rvm/rubies/ruby-1.8.7-p371
PATH=/home/username/.rvm/gems/ruby-1.8.7-p371@global/bin:/home/username/.rvm/rubies/ruby-1.8.7-p371/bin:/home/username/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
RUBY_VERSION=ruby-1.8.7-p371
rvm_bin_path=/home/username/.rvm/bin
rvm_delete_flag=0
rvm_path=/home/username/.rvm
rvm_prefix=/home/username
rvm_ruby_string=ruby-1.8.7-p371
rvm_sticky_flag=1
rvm_use_flag=1
rvm_version=1.17.7 (stable)
通过 RVM 卸载并安装 1.8.7 跑:
rvm install 1.8.7 --verify-downloads 1
并且成功了。
最佳答案
看来您运行的 gem
版本可能错误。在我的 RVM 设置中,使用 shell 命令覆盖推荐的 RVM(.bashrc
或 .zshrc 中的
或其他合适的启动文件),source "$HOME/.rvm/scripts/rvm"
gem
通常是一个 shell 函数。它在幕后执行了一些 RVM 魔法,然后运行真正的 gem 命令。就我而言,ruby
和 gem
都在同一版本目录中运行:
/home/jim/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/home/jim/.rvm/rubies/ruby-1.9.3-p327/bin/gem
确保您正在获取 RVM 启动脚本。
你的PATH
看起来没问题。确保您有 /home/username/.rvm/rubies/ruby-1.8.7-p371/bin/gem
命令。如果没有,您可能需要重新安装 ruby-1.8.7。
运行rvm current
将显示正在使用的Ruby版本和gemset。确保路径中有与 Ruby 版本匹配的 gem
。
关于ruby-on-rails - RVM bundle 程序已安装错误 : Gem bundler is not installed, 首先运行 `gem install bundler`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15441920/