通常情况下,同一台服务器上,我们需要用多种ruby版本的项目,但普通的方式一直在设置全局的ruby版本,这样会影响其他项目,所以今天找了设置.rvmrc的方法
1. 进入项目目录下, 先创建一个gemset
名字自己可以自选,自己清晰就好 kol268
rvm gemset create kol268
2. 进入项目根目录下, 创建 .rvmrc 文件
rvm use 2.6.8@kol268
3. 重新进入项目目录下,会提示以下内容,直接y回车即可
这里以后,进入项目目录下自动切换ruby版本,退出项目目录,切换回原版本
******************************************************************************
* NOTICE *
******************************************************************************
* RVM has encountered a new or modified .rvmrc file in the current *
* directory, this is a shell script and therefore may contain any shell *
* commands. *
* *
* Examine the contents of this file carefully to be sure the contents are *
* safe before trusting it! *
* Do you wish to trust '/home/rzyt/project/kol_tracking/.rvmrc'? *
* Choose v[iew] below to view the contents *
******************************************************************************
y[es], n[o], v[iew], c[ancel]> y
Using /usr/share/rvm/gems/ruby-2.6.8 with gemset kol268