Pages (Jekyll) failing to compile upon commit to repo

I’m trying to get my Gitlab Pages (Jekyll) to compile after pushing my repo, yet I’m running into the following error.

...
Created fresh repository. 
Checking out be8f11a3 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script  
Using docker image sha256:48d9aa5539017f6b4c8a465a4aae0a80499ae64e00c2783f83e98180a441e615 for ruby:2.6 with digest ruby@sha256:b6b54f72542d4597d041b48743290a38ac1095a66800c11e60be6abc170f325f ...
$ bundle update listen
This Bundle hasn't been installed yet. Run `bundle install` to update and
install the bundled gems.
Cleaning up file based variables
ERROR: Job failed: exit code 1

Here is my is my .gitlab-ci.yml file.

image: ruby:2.6

variables:
  JEKYLL_ENV: production
  LC_ALL: C.UTF-8

before_script:
  - bundle update listen
  - bundle install

test:  
  stage: test
  script:
    - bundle exec jekyll build -d test/
  artifacts:
    paths:
      - test
  except:
    - master

pages:
  stage: deploy
  script:
    - bundle exec jekyll build -d public/
  artifacts:
    paths:
      - public
  only:
    - master

What I don’t understand is why it says the bundle hasn’t been installed, and that I should run bundle install to update and install the bundled gems. Surely this can’t mean on my local machine. Though if I do run bundle install which creates a Gemfile.lock and then I check that in, I just get another error saying it’s missing the bundler like follows:

...
$ bundle update listen` `/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.2.16) required by your /builds/openjak/openjak.gitlab.io/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler. 
To install the missing version, run `gem install bundler:2.2.16
 from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
 from /usr/local/bin/bundle:23:in `<main>'
Cleaning up file based variables  
ERROR: Job failed: exit code 1

Thoughts?

Hi @srad I think you need something like this:

image: ruby:2.6

variables:
  JEKYLL_ENV: production
  LC_ALL: C.UTF-8

cache:
  key: $CI_COMMIT_REF
  paths:
    - vendor/bundle

before_script:
  - gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
  - bundle update listen
  - bundle install

...

Caching is not exactly necessary, but it might help to speed up your pipelines a little.

Thanks, now I understand what’s going on. Fixed.

1 Like