Error while running CI: don't have write permission for gem install

I’m setting up the CI for our repo on our CE, source-installed, on our server GitLab. I have upgraded it to 8.1 right now. I am using a Shell runner. I’m running into this issue:

Running with gitlab-ci-multi-runner 1.9.1 (b23d3d4)
Using Shell executor...
Running on server...
Cloning repository...
Cloning into '/home/gitlab-runner/builds/6a667e22/0/myrepo/myrepo'...
Checking out a364c4ed as my-branch...
Gemset 'myrepo' does not exist, 'rvm ruby-2.1.5 do rvm gemset create myrepo' first, or append '--create'.
Gemset 'myrepo' does not exist, 'rvm ruby-2.1.5 do rvm gemset create myrepo' first, or append '--create'.
Gemset 'myrepo' does not exist, 'rvm ruby-2.1.5 do rvm gemset create myrepo' first, or append '--create'.
$ whoami
gitlab-runner
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
$ gem install bundler --no-ri --no-rdoc
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1 directory.
ERROR: Build failed: exit status 1

Does GitLab CI use RVM? I do have rvm installed, but I did a single-user build, so I wouldn’t expect gitlab-runner to be trying to use it. and when I sudo su gitlab-runner and cd into the build folder it doesn’t complain about rvm at all, which is interesting. Hoping someone might have a similar experience, let me know if you need more info.

What does your .gitlab-ci.yml file look like? You probably want to have a Docker container that gives you Ruby 2.1 out-of-the-box.

Starting with something like this should do it for you:

image: ruby:2.1

Hey Connor! My .gitlab-ci.yml is pretty simple:

before_script:
  - ruby -v
  - which ruby
  - gem install bundler --no-ri --no-rdoc
  - bundle install --jobs $(nproc)  "${FLAGS[@]}"

rspec:
  script:
    - bundle exec rspec

I would love to do a Docker runner, and I tried it, but ran into a weird error, which I believe was related to having a kernel version less than required (according to https://docs.docker.com/engine/installation/linux/ubuntulinux/)