背景

git clone一个Ruby```项目到本地后,通过以下命令来更新软件包依赖:
1
2
```
$ bundle install --without production

但是被提示:

1
Your Ruby version is 2.4.2, but your Gemfile specified 2.3.0

此时就需要在该项目下使用2.3.0版本的Ruby。

Gemset介绍

Ruby与Rails的组合

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$ rvm list
rvm rubies

ruby-2.3.0 [ x86_64 ]
=* ruby-2.4.2 [ x86_64 ]

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

$ rvm use 2.3.0
Using /Users/katherine/.rvm/gems/ruby-2.3.0
$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16]
$ rails -v
Rails 4.2.6
$ rvm gemset create rails426
ruby-2.3.0 - #gemset created /Users/katherine/.rvm/gems/ruby-2.3.0@rails426
ruby-2.3.0 - #generating rails426 wrappers........
$ rvm use 2.3.0@rails426
Using /Users/katherine/.rvm/gems/ruby-2.3.0 with gemset rails426
$ rvm gemset list
gemsets for ruby-2.3.0 (found in /Users/katherine/.rvm/gems/ruby-2.3.0)
(default)
global
=> rails426

$ rvm use 2.4.2
Using /Users/katherine/.rvm/gems/ruby-2.4.2
$ rvm gemset list
gemsets for ruby-2.4.2 (found in /Users/katherine/.rvm/gems/ruby-2.4.2)
=> (default)
global