RVM 使用问题集锦
使用Mac进行软件开发过程中,经常遇到使用ruby的各种配置问题, 所以大家经常会使用rvm包管理工具解决它.
1. Warning! PATH is not properly set up, is not at first place 警告
解决方式: 将 .profile , .bash_profile , .zshrc 中配置的信息清楚, 只需要一个地方配对就可以了。
在 .bashrc中添加如下代码
## rvm
PATH="$GEM_HOME/bin:$HOME/.rvm/bin:$PATH" # Add RVM to PATH for scripting
[ -s ${HOME}/.rvm/scripts/rvm ] && source ${HOME}/.rvm/scripts/rvm
2. jenkins中使用 fastlane cocoapods等经常遇到 command not found 问题
这都是因为环境变量没有配置正确的问题
- 如问题1中配置好 rvm 的
Add RVM to PATH echo $PATH,拷贝打印出的PATH- 将
$PATH复制 放入 jenkins的系统配置中

3. /Library/Ruby/Site/2.0.0/rubygems.rb:271:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
jenkins中使用 Ruby, 发现使用的还是 系统的ruby.
问题描述:
Warning: PATH set to RVM ruby but GEM_HOME and/or GEM_PATH not set, see https://github.com/rvm/rvm/issues/3212
解决方案:
- 插件中心 下载安装
RVM的插件 - 然后在Job 工程里面 Build Environment 中 设置
rvm中 use 的ruby版本信息 - 如
Run the build in a RVM-managed environment设置 ruby的2.5.0版本

Discussion