安装了Ruby 2.4,但是当我还在展示Ruby 2.3时

时间:2017-01-03 17:35:32

标签: ruby-on-rails ruby macos rvm

我正在尝试在我的Mac Sierra机器上安装Ruby 2.4。我以为我成功地做到了......

localhost:myproject nataliab$ rvm use 2.4.0
Warning! PATH is not properly set up, '/Users/nataliab/.rvm/gems/ruby-2.3.0/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.3.0'.
ruby-2.4.0 is not installed.
To install do: 'rvm install ruby-2.4.0'
localhost:myproject nataliab$ rvm install ruby-2.4.0
Warning! PATH is not properly set up, '/Users/nataliab/.rvm/gems/ruby-2.3.0/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.3.0'.
Warning, new version of rvm available '1.28.0', you are using older version '1.26.11'.
You can disable this warning with:    echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.4.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating certificates in '/usr/local/etc/openssl/cert.pem'.
Requirements installation successful.
Warning: DYLD_LIBRARY_PATH environment variable is set, this might interact with the compilation and ruby.
Installing Ruby from source to: /Users/nataliab/.rvm/rubies/ruby-2.4.0, this may take a while depending on your cpu(s)...
ruby-2.4.0 - #downloading ruby-2.4.0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11.9M  100 11.9M    0     0  2715k      0  0:00:04  0:00:04 --:--:-- 2880k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.4.0 - #extracting ruby-2.4.0 to /Users/nataliab/.rvm/src/ruby-2.4.0....
ruby-2.4.0 - #configuring..................................................................
ruby-2.4.0 - #post-configuration.
ruby-2.4.0 - #compiling.............................................................
ruby-2.4.0 - #installing.......
ruby-2.4.0 - #making binaries executable..
Installed rubygems 2.6.8 is newer than 2.4.8 provided with installed ruby, skipping installation, use --force to force  installation.
ruby-2.4.0 - #gemset created /Users/nataliab/.rvm/gems/ruby-2.4.0@global
ruby-2.4.0 - #importing gemset /Users/nataliab/.rvm/gemsets/global.gems...............................................
ruby-2.4.0 - #generating global wrappers........
ruby-2.4.0 - #gemset created /Users/nataliab/.rvm/gems/ruby-2.4.0
ruby-2.4.0 - #importing gemsetfile /Users/nataliab/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.0 - #generating default wrappers........
ruby-2.4.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.4.0 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri

然后我看到了正确的Ruby版本......

localhost:myproject nataliab$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

但是当我打开一个新的终端窗口时,导航到我的项目目录,我不再看到新安装的版本......

localhost:myproject nataliab$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16]

如何让我的版本坚持下去?

2 个答案:

答案 0 :(得分:0)

更改默认 ruby​​

$ rvm default ruby-2.4.0
$ rvm list

#rvm rubies

#   ruby-2.3.0 [ x86_64 ]
#=* ruby-2.4.0 [ x86_64 ]
#   ruby-head [ x86_64 ]

## => - current
## =* - current && default
##  * - default

答案 1 :(得分:0)

在项目目录

  • 不要在Gemfile中添加任何'ruby“2.4.0”'行
  • 如果有.rvmrc文件删除它
  • 创建文件(至少有一些rvm版本需要存在版本和gemset文件)

.ruby版本

2.4.0

.ruby-宝石 app

触发rvm重新加载它们 cd . ruby --version rvm gemset list

  • 安装2.4.0的捆绑包(如果缺少) rvm 2.4.0@global do gem install bundler