Error: Permission denied @ rb_sysopen

I set up this CI script to deploy my site to Codeberg Pages:

pipeline:
  publish:
    image: jekyll/jekyll
    secrets: [ codeberg_access_token ]
    commands:
      - bundle install
      - bundle exec jekyll build
      - cd _site
      - git init
      - git remote add up $CODEBERG_ACCESS_TOKEN@https://codeberg.org/mikwee/pages.git
      - git push -u up master -f

Unfortunately, when the CI tried to run it:

+ bundle install
Bundler 2.3.15 is running, but your lockfile was generated with 2.3.7. Installing Bundler 2.3.7 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.7
Installing bundler 2.3.7
Fetching gem metadata from https://rubygems.org/.........
Using concurrent-ruby 1.1.10
Using minitest 5.15.0
Using thread_safe 0.3.6
Fetching zeitwerk 2.5.4
Using public_suffix 4.0.7
Using bundler 2.3.7
Fetching coffee-script-source 1.11.1
Installing zeitwerk 2.5.4
Installing coffee-script-source 1.11.1
Using execjs 2.8.1
Using colorator 1.1.0
Using commonmarker 0.23.5
Using eventmachine 1.2.7
Fetching unf_ext 0.0.8.2
Using http_parser.rb 0.8.0
Using ffi 1.15.5
Fetching faraday-net_http 2.0.3
Installing faraday-net_http 2.0.3
Using ruby2_keywords 0.0.5
Using forwardable-extended 2.6.0
Using gemoji 3.0.1
Using rb-fsevent 0.11.1
Using rexml 3.2.5
Using liquid 4.0.3
Using mercenary 0.3.6
Fetching rouge 3.26.0
Installing unf_ext 0.0.8.2 with native extensions
Installing rouge 3.26.0
Using safe_yaml 1.0.5
Using racc 1.6.0
Using jekyll-paginate 1.1.0
Fetching rubyzip 2.3.2
Installing rubyzip 2.3.2
Fetching jekyll-swiss 1.0.0
Installing jekyll-swiss 1.0.0
Using unicode-display_width 1.8.0
Using parallel 1.22.1
Using rainbow 3.1.1
Using yell 2.2.2
Fetching webrick 1.7.0
Installing webrick 1.7.0
Using i18n 0.9.5
Using tzinfo 1.2.9
Using addressable 2.8.0
Using coffee-script 2.4.1
Using jekyll-commonmark 1.4.0
Using em-websocket 0.5.3
Using ethon 0.15.0
Using rb-inotify 0.10.1
Fetching faraday 2.3.0
Installing faraday 2.3.0
Using pathutil 0.16.2
Fetching kramdown 2.3.2
Installing kramdown 2.3.2
Using nokogiri 1.13.6 (x86_64-linux)
Fetching terminal-table 1.8.0
Installing terminal-table 1.8.0
Fetching activesupport 6.0.5
Installing activesupport 6.0.5
Fetching jekyll-coffeescript 1.1.1
Installing jekyll-coffeescript 1.1.1
Using typhoeus 1.4.0
Using sass-listen 4.0.0
Using listen 3.7.1
Fetching sawyer 0.9.1
Using kramdown-parser-gfm 1.1.0
Fetching unf 0.1.4
Installing sawyer 0.9.1
Using html-proofer 3.19.4
Using sass 3.7.4
Using jekyll-watch 2.2.1
Using html-pipeline 2.14.1
Fetching octokit 4.23.0
Installing unf 0.1.4
Using jekyll-sass-converter 1.5.2
Fetching simpleidn 0.2.1
Installing simpleidn 0.2.1
Installing octokit 4.23.0
Using jekyll 3.9.2
Fetching dnsruby 1.61.9
Fetching jekyll-avatar 0.7.0
Installing jekyll-avatar 0.7.0
Installing dnsruby 1.61.9
Fetching jekyll-commonmark-ghpages 0.2.0
Installing jekyll-commonmark-ghpages 0.2.0
Fetching jekyll-default-layout 0.1.4
Fetching jekyll-feed 0.15.1
Installing jekyll-default-layout 0.1.4
Fetching jekyll-include-cache 0.2.1
Installing jekyll-feed 0.15.1
Using jekyll-mentions 1.6.0
Fetching jekyll-optional-front-matter 0.3.2
Installing jekyll-include-cache 0.2.1
Fetching jekyll-readme-index 0.3.0
Installing jekyll-optional-front-matter 0.3.2
Using jekyll-redirect-from 0.16.0
Fetching jekyll-relative-links 0.6.1
Installing jekyll-readme-index 0.3.0
Installing jekyll-relative-links 0.6.1
Fetching jekyll-remote-theme 0.4.3
Using jekyll-seo-tag 2.8.0
Using jekyll-sitemap 1.4.0
Fetching jekyll-titles-from-headings 0.5.3
Installing jekyll-remote-theme 0.4.3
Installing jekyll-titles-from-headings 0.5.3
Using jemoji 0.12.0
Fetching jekyll-paginate-v2 2.0.0
Fetching jekyll-gist 1.5.0
Installing jekyll-gist 1.5.0
Fetching jekyll-github-metadata 2.13.0
Installing jekyll-github-metadata 2.13.0
Installing jekyll-paginate-v2 2.0.0
Fetching github-pages-health-check 1.17.9
Fetching jekyll-theme-architect 0.2.0
Installing github-pages-health-check 1.17.9
Fetching jekyll-theme-cayman 0.2.0
Installing jekyll-theme-architect 0.2.0
Fetching jekyll-theme-dinky 0.2.0
Installing jekyll-theme-cayman 0.2.0
Fetching jekyll-theme-hacker 0.2.0
Installing jekyll-theme-dinky 0.2.0
Fetching jekyll-theme-leap-day 0.2.0
Installing jekyll-theme-hacker 0.2.0
Fetching jekyll-theme-merlot 0.2.0
Installing jekyll-theme-leap-day 0.2.0
Installing jekyll-theme-merlot 0.2.0
Fetching jekyll-theme-midnight 0.2.0
Fetching jekyll-theme-minimal 0.2.0
Installing jekyll-theme-minimal 0.2.0
Fetching jekyll-theme-modernist 0.2.0
Installing jekyll-theme-midnight 0.2.0
Installing jekyll-theme-modernist 0.2.0
Fetching jekyll-theme-slate 0.2.0
Installing jekyll-theme-slate 0.2.0
Fetching jekyll-theme-tactile 0.2.0
Fetching jekyll-theme-time-machine 0.2.0
Installing jekyll-theme-tactile 0.2.0
Installing jekyll-theme-time-machine 0.2.0
Using minima 2.5.1
Fetching jekyll-theme-primer 0.6.0
Installing jekyll-theme-primer 0.6.0
Fetching github-pages 226
Installing github-pages 226
Bundle complete! 8 Gemfile dependencies, 97 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
1 installed gem you directly depend on is looking for funding.
Run `bundle fund` for details
+ bundle exec jekyll build
Configuration file: /woodpecker/src/codeberg.org/mikwee/personal-site/_config.yml
Source: /woodpecker/src/codeberg.org/mikwee/personal-site
Destination: /woodpecker/src/codeberg.org/mikwee/personal-site/_site
Incremental build: disabled. Enable with --incremental
Generating...
AutoPages: Disabled/Not configured in site.config.
Pagination: Disabled in site.config.
Jekyll Feed: Generating feed for posts
jekyll 3.9.2 | Error: Permission denied @ rb_sysopen - /woodpecker/src/codeberg.org/mikwee/personal-site/_site/404.html
/usr/gem/gems/jekyll-3.9.2/lib/jekyll/convertible.rb:228:in `write': Permission denied @ rb_sysopen - /woodpecker/src/codeberg.org/mikwee/personal-site/_site/404.html (Errno::EACCES)
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/convertible.rb:228:in `write'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:209:in `block in write'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:332:in `block (2 levels) in each_site_file'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:331:in `each'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:331:in `block in each_site_file'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:330:in `each'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:330:in `each_site_file'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:208:in `write'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/site.rb:73:in `process'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/command.rb:28:in `process_site'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/commands/build.rb:65:in `build'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/commands/build.rb:36:in `process'
from /usr/gem/gems/jekyll-3.9.2/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
from /usr/gem/gems/jekyll-3.9.2/exe/jekyll:15:in `<top (required)>'
from /usr/gem/bin/jekyll:25:in `load'
from /usr/gem/bin/jekyll:25:in `<top (required)>'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in `load'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:23:in `run'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/cli.rb:484:in `exec'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/cli.rb:31:in `dispatch'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/cli.rb:25:in `start'
from /usr/gem/gems/bundler-2.3.7/exe/bundle:48:in `block in <top (required)>'
from /usr/gem/gems/bundler-2.3.7/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
from /usr/gem/gems/bundler-2.3.7/exe/bundle:36:in `<top (required)>'
from /usr/local/bin/bundle:25:in `load'
from /usr/local/bin/bundle:25:in `<main>'

Does anybody here have any idea of what might be happening here? Thank you.

I’m not an expert here, but it looks like the very first error (second line) had to be cleared up. Your gemfile.lock was made with a newer version of bundled, so you should install that as a first step:

gem install bundler

There are options to force a specific version. Here’s the doc:

https://bundler.io/guides/bundler_2_upgrade.html