evan evan - 1 year ago 146
Ruby Question

Jekyll sitemap not building in Gitlab

Including the

gem when pushing to Gitlab.io makes the build fail. When I run jekyll locally, sitemap.xml is correctly generated in my _site folder.

What do I need to do in order to get the
gem to build in Gitlab? Or alternatively should I somehow exclude the
gem before pushing to Gitlab?


source "https://rubygems.org"
ruby '2.0.0'
gem 'jekyll'
gem 'jekyll-sitemap'
gem 'sass'


- jekyll-sitemap

Gitlab Build Output

$ gem install jekyll
Successfully installed safe_yaml-1.0.4
Successfully installed rouge-1.10.1
Successfully installed mercenary-0.3.6
Successfully installed liquid-3.0.6
Successfully installed kramdown-1.11.1
Building native extensions. This could take a while...
Successfully installed ffi-1.9.10
Successfully installed rb-inotify-0.9.7
Successfully installed rb-fsevent-0.9.7
Successfully installed listen-3.0.7
Successfully installed jekyll-watch-1.4.0
Successfully installed sass-3.4.22
Successfully installed jekyll-sass-converter-1.4.0
Successfully installed colorator-0.1
Successfully installed jekyll-3.1.3
14 gems installed
$ jekyll build -d public/
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:94:in `block in materialize': Could not find jekyll-sitemap-0.10.0 in any of the sources (Bundler::GemNotFound)
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `map!'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `materialize'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:137:in `specs'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:182:in `specs_for'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/definition.rb:171:in `requested_specs'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/environment.rb:18:in `requested_specs'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:13:in `setup'
from /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'
from /usr/local/bundle/gems/jekyll-3.1.3/lib/jekyll/plugin_manager.rb:33:in `require_from_bundler'
from /usr/local/bundle/gems/jekyll-3.1.3/bin/jekyll:9:in `<top (required)>'
from /usr/local/bundle/bin/jekyll:22:in `load'
from /usr/local/bundle/bin/jekyll:22:in `<main>'

My terminal output after running

Using colorator 0.1
Using ffi 1.9.10
Using sass 3.4.22
Using jekyll-sass-converter 1.4.0
Using rb-fsevent 0.9.7
Using rb-inotify 0.9.7
Using listen 3.0.7
Using jekyll-watch 1.4.0
Using kramdown 1.11.1
Using liquid 3.0.6
Using mercenary 0.3.6
Using rouge 1.10.1
Using safe_yaml 1.0.4
Using jekyll 3.1.3
Using jekyll-sitemap 0.10.0
Using bundler 1.10.6
Bundle complete! 3 Gemfile dependencies, 16 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

Answer Source

Edited answer :

In fact, the answer was in your .gitlab-ci.yml. I guess that this file contains something like :

  stage: deploy
    - gem install jekyll
    - jekyll build -d public

If you want to run gitlab-ci this way (without bundler), this file must contains something like :

  stage: deploy
    - gem install jekyll
    - gem install jekyll-sitemap
    - jekyll build -d public

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

See gitlab-ci documentation

Old answer : Why don't you use bundle exec jekyll build -d public/ ?