-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundler 2.2.5 still doesn't fallback to source gem when platform specific gem is unusable #4282
Comments
Yes, definitely. This should work. I suspect bundler resolution is sometimes falling back to the old gem dependency API which didn't have I don't know why this is happening, but we have received two reports about this in the last 2 days, hence my suspicion. It could be a server side issue too, I'll investigate. Can you post some logs that I can see, ideally in verbose mode so we can see the network requests being made. I suspect this is not reproducible reliably, correct? |
Our gemfile is huge and contains lots of private gems. I'll try to better reproduce in isolation and provide logs.
Yes. I'm trying to pinpoint it exactly, but it isn't quite trivial. I'll try to come back with a repro script. |
Ok, I think I figured it out:
Ruby 2.7.2:
Then
So the problem seem to be that our I'll see if I can find a workaround for us, but this seems like a bug to me. It's not uncommon to use the same Gemfile.lock concurrently with different ruby versions. |
Oh, I see... But, how can we solve that? In this case two different ruby versions have two different resolutions. I think if you want to reuse the same lockfile for both rubies you could use #4049, making the compromise of giving up on platform specific variants for this gem. I'm open to suggestions. |
There might be more to it though, because in our app I don't see the compiled gem being listed in Gemfile.lock:
I'm afraid I'm not familiar enough with bundler internal to offer much help on this. Couldn't bundler always list the source gem even when it select the platform specific one? Or list all variants? I haven't dug much yet, but that |
I've wished for this feature for a while. It wouldn't be perfect, but at least it would unblock me I think. |
Can you try |
It did:
I'm afraid not:
|
More logs:
|
That's unexpected, I would expect Sorry for the issues you're having, a correct multiplatform resolution turned out to be much harder than I was expecting 🙏. |
No worries, I mostly blame And lots of thanks for trying to make this work, I'll try to figure a workaround in the meantime. I used to have a shitty monkey patch to force these gems be source gems, but it no longer works on if RUBY_VERSION >= '3.0'
module BundlerHack
def __materialize__
if name == 'google-protobuf'
Bundler.settings.temporary(force_ruby_platform: true) do
super
end
else
super
end
end
end
Bundler::LazySpecification.prepend(BundlerHack)
end |
So I don't quite understand how or why, but but looking at the diffs better I saw that 2.7 had So I manually edited the
And it now install properly on 3.0. That's really puzzling to me though. |
@casperisfine i just manually added |
You mean why bundler doesn't fallback to source? No not yet. |
I'll try to get this fixed this week. |
Ok, so there's a few related issues here.
Try for example running
And then switch to ruby 2.4 and run
I think you can solve this by removing the specific platform from the lockfile, and locking only for ruby. So, As something we can improve on our side, I think we can check whether all locked specs are compatible with the running ruby version, and re-resolve if not. So you would get lockfile changes when switching rubies, but bundler will install fine. And finally, as I third issue I'm completely puzzled about, I have no idea how |
Ok TIL. This had worked for us until now, it was very convenient for Ruby upgrades. We'll figure out a new strategy then.
It's pretty much what I posted above: Start with this Gemfile: source 'https://rubygems.org'
gem 'grpc' using ruby 2.7.2: $ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
$ bundle --version
Bundler version 2.2.5
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 2.2.5
Using google-protobuf 3.14.0 (universal-darwin)
Using googleapis-common-protos-types 1.0.5
Using grpc 1.34.0 (universal-darwin)
Bundle complete! 1 Gemfile dependency, 4 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$ cat Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
google-protobuf (3.14.0-universal-darwin)
googleapis-common-protos-types (1.0.5)
google-protobuf (~> 3.11)
grpc (1.34.0-universal-darwin)
google-protobuf (~> 3.13)
googleapis-common-protos-types (~> 1.0)
PLATFORMS
x86_64-darwin-19
DEPENDENCIES
grpc
BUNDLED WITH
2.2.5
$ bundle lock --add-platform ruby
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Writing lockfile to /private/tmp/bundler-repro/Gemfile.lock
$ cat Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
google-protobuf (3.14.0)
google-protobuf (3.14.0-universal-darwin)
googleapis-common-protos-types (1.0.5)
google-protobuf (~> 3.11)
grpc (1.34.0)
google-protobuf (~> 3.13)
googleapis-common-protos-types (~> 1.0)
grpc (1.34.0-universal-darwin)
google-protobuf (~> 3.13)
googleapis-common-protos-types (~> 1.0)
PLATFORMS
ruby
x86_64-darwin-19
DEPENDENCIES
grpc
BUNDLED WITH
2.2.5
|
I'd like to support re-resolving if the current ruby can't satisfy the lockfile, but it's tricky because we don't currently record Regarding the issue, what you posted now makes sense and it's expected. I think maybe there's was just some typos in #4282 (comment) and that caused the confusion? The diff you posted there makes it look like |
Bringing this thread back as I'm hitting the same nokogiri issue than in sparklemotion/nokogiri#2185 Gemfile: source 'https://rubygems.org'
gem 'nokogiri' Gemfile.lock:
trying to bundle with 3.1.0-dev:
Why is bundler trying to use the precompiled gem even though it's not in the Gemfile.lock? I understand that you said bundling across versions isn't officially supported, but in this specific case I really fail to see why it wouldn't work (even if it's by accident)
I'm not super familiar with the bundler internals, but can't we instead always list all the alternative gems in the That would be enough to solve 99% of the cross version bundling pains. Because we're trying to run our test suite against Ruby-head, but if we have to nuke our |
Hi.
This is for backwards compatibility with old lockfiles. If the specific platform is not there, we assume it's a lockfile not generated with recent versions (which lock the specific platform instead of "RUBY", and save platform specific variants inside the lockfile). And if it's an old lockfile, we keep the old logic of resolving platforms at install time instead of respecting what's in the lockfile. So, my plan to fix this would be:
But then if you use it with ruby 3.1, it would detect that it needs to re-resolve, and would generate a lockifle like the following and use the "RUBY" variant:
I'll try to implement the first bullet point for now to get you unblocked. |
Oh! That explains it. I thought I was going crazy for a minute.
Thank you so much! |
@casperisfine #4449 should fix your issue. I will make that issue close this ticket and then re-ticktet the remaining case (fix the same issue when specific platforms are being locked in the lockfile). |
❤️ |
Ref: rubygems/bundler#7522
From what I understood, bundler 2.2.x was supposed to fallback to compiling gems if the precompiled binaries can't be used.
But from what I experienced it still doesn't work:
Using bundler 2.2.5
The text was updated successfully, but these errors were encountered: