-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Do not rebuild native extensions on every install for git dependencies #3014
Comments
Monkey-patch: # https://github.com/bundler/bundler/issues/3014
# Do not re-build native extensions: speedup + avoiding crashing already running apps
# in Gemfle
Bundler::GemInstaller.class_eval do
def build_extensions
marker = "#{gem_dir}/ext-built"
return if File.exist?(marker)
result = super
File.write(marker, "true")
result
end
end before: 1.2s for bundle + running apps crash when re-bundling |
This is a good idea, if your monkey-patch makes it impossible to ever update the gem. You’ll keep using that old c-ext for the rest of your life, no matter how many times the git repo gets new commits and you update to use them. On May 6, 2014, at 12:20 PM, Michael Grosser notifications@github.com wrote:
|
already tried that, new version will have a new sha -> different folder, so On Sun, May 11, 2014 at 3:02 AM, André Arko notifications@github.comwrote:
|
He's right, @indirect. I'm assigning this to myself and adding a test / fix for it. |
@grosser I've spent some time thinking about this and came up with the following question: wouldn't your patch make it so that if I package, say, a Rails app, it wouldn't recompile even if it was under a different system? |
it would not do the same for normal gems, right ? On Tue, May 13, 2014 at 9:51 AM, André Medeiros notifications@github.comwrote:
|
+1 for this issue. We've noticed when we deploy to a running instance, bundle install will replace the native-library in a c-extension and that causes Passenger to fail if that gem happens to be accessed at the same time. Until it is restarted, Passenger appears to continue to fail on calls to that gem. |
@andremedeiros any progress on this one? I would like to include this fix in the next release. :) |
@andremedeiros is right: this causes the a git gem cached on one platform not to rebuild when you install on another platform... someone who was unwittingly using this monkey patch reported this on IRC. We'll need a solution to that before we incorporate this change. Maybe something as simple as dropping the ext-built file in a platform-specific directory? It would probably be a good idea to have a flag to force a rebuild, too. |
I'm with @TimMoore. We need to finger-print the machine (and repeatable throughout similar setups.) |
I'm unclear on how you can install an already-compiled git extension on a different platform? Bundler explicitly doesn't support copying installed bundles between machines. |
This is when you |
Yeah, that is a bit weird. :/ At a minimum, they shouldn't be checked in, but I would expect to clone from that repo as part of install as usual so that install creates a clean copy and a new built extension for the computer being installed on. On Wed, Jul 2, 2014 at 10:22 PM, Tim Moore notifications@github.com
|
Essentially, it looks like Bundler treats a cached git repo like a path repo, except that it also builds extensions. |
@indirect @TimMoore I met the situation, I need to package my web app and all my gems including git repos to vendor/cache, and deploy the package to an environment without Internet connection in other platform. Maybe bundler can just try to remove old extension building outputs, so that it would not break |
+1, @grosser's patch just fixed a big issue for us, where one of our C extensions would be recompiled during a deploy, when it ran bundle install. If someone happened to hit a controller action that called the extension, it would take our site down until the webserver processes were restarted at the end of the deploy. Same for any background workers that called out to the extension. |
The solution to this problem is probably to build extensions into a platform-specific directory, the way Rubygems now does for installed gems with extensions. We'll still need to include the sha in the platform-specific directory name, though. |
+1, this is an issue for us too. |
👍 We run into this or a similar issue with the
We have |
👍 bon courage working on this ! |
@indirect / @andremedeiros this can be closed as of 1.12.0.pre.2, no? |
I think so, yes. |
given a Gemfile with a native extensions
the native extension should not be rebuild if it already was build the last time around
basically make lib/bundler/source/path.rb:188 smarter
this should bring extra speed when bundling + allow to re-bundle without having a running app try to load a invalid/missing c extension
The text was updated successfully, but these errors were encountered: