Hi there! I’ve been struggling with this problem for a few months & finally have found a solution, but I think there might be a better way to handle it to better take advantage of Netlify’s power. Any help is greatly appreciated!
Briefly summarize the issues you have been experiencing.
For several of my sites, the build & deploy would regularly fail unless I clicked the “Retry deploy & clear cache” option. These are Jekyll sites, but use Gulp as a task runner to compile CSS, JS, and run bundle exec jekyll build
. The build command I have Netlify use is npm run build
(as opposed to jekyll build
). Any time the cache was used, the build would fail because it couldn’t find a particular gem public_suffix
(a dependency of a dependency of Jekyll). This is because bundle install
was run as a preinstall script, and for whatever reason, Netlify wasn’t caching the result of that script and the preinstall wasn’t run once a cache is created.
NPM Scripts used:
"scripts": {
"preinstall": "bundle install --path vendor/bundle",
"start": "gulp",
"build": "gulp build --jekyllEnv='production'",
}
I do have a Gemfile that includes the Jekyll gem as well.
What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?
I’ve been able to fix the problem of those gems not being available by adding a prebuild
step that duplicates the preinstall
, like this:
"prebuild": "bundle install --path vendor/bundle",
The “issue” I’m running into with this solution is that now Netlify isn’t caching any of the Jekyll gems used, which slows down the deploy. It isn’t a significant amount, but I’m sure there is probably a better way to do this that would allow Netlify to cache those gems so they don’t have to be reinstalled every time a build is done.
Live Site URL: https://healthsecurity.csis.org/
GitHub Repo: GitHub - CSIS-iLab/health-commission
Thanks in advance for any help!