Runner fails to work with RVM in MacOS X environment

Summary

We've noticed shell runner behavior on Mac OS X, when it fails build if there's a script action with ruby rvm involved

Steps to reproduce

Add script action containing following line or any other involving RVM:

before_script:
 - rvm use ruby-2.4.1 --install

Actual behavior

It produces following output:

Using Shell executor...
Running on MacServer.local...
Fetching changes...
...
Skipping Git submodules setup
$ rvm use ruby-2.4.1 --install
ERROR: Job failed: exit status 1

If we try:

source /etc/profile.d/rvm.sh

Runner fails on the line above with same error.

Expected behavior

  • Build does not fail
  • Ruby environment switches to requested version

Relevant logs and/or screenshots

Problem does not lie in bash environment not being correctly loaded to use RVM. If we add following step to CI script:

 - type rvm

We receive expected output:

$ type rvm
rvm is a function
rvm () 
{ 
    \typeset result current_result;
    rvm_ruby_args=();
...

So RVM was loaded on bash shell invokation of ~/.bash_profile We can put it in separate script and invoke it in script action, but all changes to environment will be lost after this step finishes. Any further actions involving ruby env will be continued with system-provided ruby.

Behavior is identical, whether CI is being run from GitLab pipeline or locally in debug mode.

Environment description

  • Custom installation of Gitlab.
  • MacOS X 10.12.4
  • RVM 1.29.1 (latest)

Used GitLab Runner version

Version:      9.2.0
Git revision: adfc387
Git branch:   9-2-stable
GO version:   go1.7.5
Built:        Mon, 22 May 2017 16:01:10 +0000
OS/Arch:      darwin/amd64