How to use specific bundler version in V2?
I was excited to see the build cache feature, which needs the v2 build system enabled.
In v1, the version of bundler is detected from the Gemfile.lock file, but in v2 this seems not to be the case.
At https://developers.cloudflare.com/pages/platform/language-support-and-tools/ it shows "Corresponds with Ruby version" for Supported versions, but there aren't any instructions about configuring it.
What's the appropriate way to configure the version of bundler?
I have tried updating the version, and using BUNDLER_VERSION env variable, but same result.
4 Replies
I'm not super familiar with the ruby/bundler ecosystem - How do projects typically ensure the correct version of bundler is installed?
We should probably consider exposing a
BUNDLER_VERSION
but in the meantime, here's what you can do set a specific bundler version:
Add a new environment variable to your project called UNSTABLE_PRE_BUILD
with the value:
@JohnDotAwesome To be honest I'm not super familiar with the ecosystem either - we are only using it for a couple of sites with jekyll. I can say that our repo build instructions don't include anything special for setting the bundler version, so I assume it's normally picked up automatically.
The
UNSTABLE_PRE_BUILD
suggestion did indeed get the bundler working.
Though, then a new problem:
I tried a couple of solutions without success:
1. Add asdf install ruby 2.6.2 &&
to UNSTABLE_PRE_BUILD
2. Add .tool-versions
file to the repo
But what did get it working was changing the build command from jekyll build
to bundle exec jekyll build
Performance with V2 is quite a lot worse than V1. For this site, V1 builds in 1m34s, and V2 5m50s. Now I realise that build caching doesn't yet support Jekyll. Whoops!The reason why it's slower for you is it's having to install (build) a custom ruby version. v2 ships with ruby versions 2.7.8 and 3.2.2
Now 1m10s when using v2 with ruby 2.7.8, and the bundler hack is not needed either. You should mention on Language support and tools that 2.7.8 is preinstalled