Fixing cloudflare pages for jekyll blog
I encountered problems when first deploying my web page to cloudflare. I set the build configurations to Jekyll on the Framework preset. This also set the build command to jekyll build and the build output directory to _site.
However, when the project was building cloudflare i would get an error.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0:59:50.393 Executing user command: bundle exec jekyll build
20:59:50.904 bundler: failed to load command: jekyll (/opt/buildhome/.asdf/installs/ruby/3.2.2/bin/jekyll)
20:59:50.905 /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/definition.rb:524:in `materialize': Could not find html-proofer-5.0.9, async-2.21.1, nokogiri-1.16.7-x86_64-linux, pdf-reader-2.13.0, rainbow-3.1.1, typhoeus-1.4.1, yell-2.2.2, zeitwerk-2.7.1, console-1.29.0, fiber-annotation-0.2.0, io-event-1.7.4, racc-1.8.1, Ascii85-2.0.1, afm-0.2.2, hashery-2.1.2, ruby-rc4-0.1.5, ttfunk-1.8.0, ethon-0.16.0, fiber-local-1.1.0, json-2.8.2, fiber-storage-1.0.0 in locally installed gems (Bundler::GemNotFound)
20:59:50.906 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/definition.rb:197:in `specs'
20:59:50.906 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/definition.rb:254:in `specs_for'
20:59:50.907 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/runtime.rb:18:in `setup'
20:59:50.907 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler.rb:171:in `setup'
20:59:50.907 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/setup.rb:23:in `block in <top (required)>'
20:59:50.907 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/ui/shell.rb:159:in `with_level'
20:59:50.907 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/ui/shell.rb:111:in `silence'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/setup.rb:23:in `<top (required)>'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:56:in `require_relative'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:56:in `kernel_load'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:492:in `exec'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
20:59:50.908 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
20:59:50.909 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'
20:59:50.909 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:45:in `block in <top (required)>'
20:59:50.909 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
20:59:50.909 from /opt/buildhome/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:33:in `<top (required)>'
20:59:50.909 from /opt/buildhome/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `load'
20:59:50.909 from /opt/buildhome/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `<main>'
20:59:50.909 Failed: Error while executing user command. Exited with error code: 1
20:59:50.919 Failed: build command exited with code: 1
20:59:51.945 Failed: error occurred while running build command
Cloudflare automatically detects the tools in the environment and attempts to install the dependencies. However, in my case it fails due to not installing all the dependencies. The solution was to reconfigure the build settings. I created a new folder called .cloudflare and on it created a shell file called deploy.sh . Then, made the file an executable using the following command on the terminal: chmod +x .cloudflare/deploy.sh .
Here is the file to rebuild the site using bundle exec.
1
2
3
4
#!/bin/bash
bundle install --path vendor/bundle
bundle exec jekyll build
Then setup the new build configuration on cloudflare.
This fixed the problem. The cloudflare reinstalled the packages and built the jekyll site to _site and deployed it.