LoginSignup
20
20

More than 5 years have passed since last update.

Jenkinsでrvmを使おうとするとエラー

Posted at

エラー内容 その1

+ rvm use
/tmp/hudson1166277874546094993.sh: line 3: rvm: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

JenkinsのRVMプラグインやJenkinsサーバへRVMをインストールしているにもかかわらず上記エラーが発生する。
以下のログが出力されているし、RVMは認識されてるはずだと思うのだが、自作のシェルはRVMを認識してくていない。

[workspace] $ bash -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create 1.9.3 && export > rvm.env"
Using /usr/local/rvm/gems/ruby-1.9.3-p429

よくよく調査してみると、PATHにRVMが追加されていなかった。なんで?

+ env
~(省略)~
PATH=/sbin:/usr/sbin:/bin:/usr/bin

エラー内容 その2

PATHにRVMのパスを追加してみたが、今度は別のエラーが発生した。が、RVMは認識してくれるようにはなった。

+ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/rvm/bin
+ export PATH
+ rvm use
RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.

対処方法

デフォルトのシェルはshで動作するため、.bashrc等の読み込みができていなかったみたい。なので、bashで起動するためシバン(#!/bin/bash)を追加してあげればOK。あとは、.bash_profileの読み込みを追加。

#!/bin/bash
source ~/.bash_profile
bundle install

p.s.
これに1週間悩み苦しみました・・・。

20
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
20