Remove the Gemfile so the build system doesn’t read it.
I need the Gemfile in my repo for non-netlify related scripts. Is there a way to remove it programmatically before the build happens?
Not that I am aware of.
You can trick Netlify into skipping installing gems straight from within your gemfile:
return true if ENV['NETLIFY']
more discussion here: How to ignore a Gemfile when building a site - #15 by fool
This is helpful in reducing, but not eliminating the time spent unnecessarily installing Ruby dependencies. Every build still spends 10-20 seconds unnecessarily installing a version of Bundler that isn’t needed:
5:05:44 PM: Attempting Ruby version 2.7.2, read from environment
5:05:45 PM: Using Ruby version 2.7.2
5:05:45 PM: Using Bundler version 2.4.9 from Gemfile.lock
5:05:57 PM: Successfully installed bundler-2.4.9
If you start using Ruby 2.7.2 in your project, this won’t be an issue.
Not a terribly helpful suggestion, especially considering that Ruby 2.7 is EOL (and there have been several 2.7.x versions after 2.7.2).
@hrishikesh any further comment here? It’s your company that is wasting countless build-hours on this, so I would imagine this would warrant some sort of solution…
As a workaround, I have started manually deleting the
BUNDLED_WITH lines from my
Gemfile.lock, but I don’t consider this to be a viable long-term solution, as those lines have a value in the contexts where I use Bundler in my project (none of which have anything to do with Netlify)
Unfortunately there are no updates in this area.