我如何强制"捆绑安装"使用已安装的Ruby版本?

时间:2017-05-30 15:14:30

标签: ruby rubygems bundle rvm bundler

我刚刚重新安装了Ruby 2.4.0 ......

myuser@myproject:~$ sudo env "PATH=$PATH" rvm reinstall ruby-2.4.0
ruby-2.4.0 - #removing rubies/ruby-2.4.0..
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/ubuntu/14.04/x86_64/ruby-2.4.0.tar.bz2
Checking requirements for ubuntu.
Requirements installation successful.
ruby-2.4.0 - #configure
ruby-2.4.0 - #download
ruby-2.4.0 - #validate archive
ruby-2.4.0 - #extract
ruby-2.4.0 - #validate binary
ruby-2.4.0 - #setup
ruby-2.4.0 - #gemset created /usr/local/rvm/gems/ruby-2.4.0@global
ruby-2.4.0 - #importing gemset /usr/local/rvm/gemsets/global.gems...................................
ruby-2.4.0 - #generating global wrappers........
ruby-2.4.0 - #gemset created /usr/local/rvm/gems/ruby-2.4.0
ruby-2.4.0 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.0 - #generating default wrappers........
Making gemset ruby-2.4.0 pristine.................................................................
Making gemset ruby-2.4.0@global pristine.................................................................

然而,尽管我看到" ruby​​ -v"返回的正确版本,我的"捆绑安装"似乎指向旧版本的Ruby ...

rails@myproject:~$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
rails@myproject:~$ cd myproject
rails@myproject:~/myproject$ bundle install
-su: /usr/local/rvm/gems/ruby-2.4.0/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory

我是否强制捆绑指向正确版本的Ruby?

1 个答案:

答案 0 :(得分:1)

捆绑失败,因为您没有在2.4.0 rvm gemset中安装捆绑器。要解决这个问题,您应该在当前版本的ruby中执行此操作:

gem install bundler
bundle

确保您的Ruby版本与Gemfile上声明的相同。