Skip to content

Conversation

@martinemde
Copy link
Contributor

What was the end-user or developer problem that led to this PR?

Somehow, a fresh copy of rubygems is failing when running rake.

What is your fix for the problem, implemented in this PR?

Require bundler shared helpers high enough up that it fixes the issue. If someone else can figure out a better way, I'm open to that. This patch at least solves the issue for now.

Make sure the following tasks are checked

I'm not sure what changed, but multiple people are having this
issue and this fixes it.
@MSP-Greg
Copy link
Contributor

MSP-Greg commented May 8, 2024

A recent CI run in ruby openssl had a possibly similar issue (NameError: uninitialized constant Bundler::SharedHelpers).

See https://github.com/ruby/openssl/actions/runs/8999647687, the three failing Windows jobs, which all installed Bundler 2.5.10.

@simi
Copy link
Contributor

simi commented May 8, 2024

This seems to be locally problem only on Ruby 3.2. Is that possible? 🤔

@martinemde
Copy link
Contributor Author

I was using 3.3.1.

@hsbt
Copy link
Member

hsbt commented May 9, 2024

@martinemde Can you share more details? I could use gem_task without this.

$ git clean -fxd
Removing .ruby-lsp/
Removing bundler/.rspec_status
Removing bundler/pkg/
Removing bundler/spec/support/artifice/used_cassettes.txt
Removing bundler/tmp/

$ rake bundler:install
bundler 2.6.0.dev built to pkg/bundler-2.6.0.dev.gem.
bundler (2.6.0.dev) installed.

I tried with fresh repository with git clone [email protected]:rubygems/rubygems.git and rake bundler:install. It's also working.

@hsbt hsbt self-assigned this May 9, 2024
@deivid-rodriguez
Copy link
Contributor

By looking at logs posted by @MSP-Greg, it seems like the more natural place to add this require is right before https://github.com/rubygems/rubygems/blob/936827c1171a23773d0643e8fcb207bf67ec8397/bundler/lib/bundler/rubygems_ext.rb#L151.

It also explains why we never got this problem reported before, since that code was just introduced in Bundler 2.5.10.

@hsbt
Copy link
Member

hsbt commented May 10, 2024

Thanks, I got it. Should we require shared_helpers on gem_tasks?

@MSP-Greg
Copy link
Contributor

Thanks for looking at this.

Not sure how many have looked at how the error occurred. setup-ruby updates Bundler because some Windows Ruby builds do not have a bash bin-stub for Bundler. Note that the ruby-loco builds do have the bin-stub. So, with the RubyGems/Bundler combination in Ruby master, there is no error, as you can see in the ruby/openssl CI Actions logs mentioned above.

I'm not sure how @martinemde noticed the issue, as the OpenSSL logs only occurred with a Bundler upgrade. I apologize for not digging into the code to find the cause, but it does seem to only occur when Bundler 2.5.10 is used with a 'previously released' RubyGems.

Lastly, since RubyGems & Bundler are in the same repo, and testing new Bundler releases against previous RubyGems releases must be quite a PITA, maybe consideration should be given to no longer releasing Bundler gems?

Or, if one wants to update Bundler, one must do so with a RubyGems update...

@martinemde
Copy link
Contributor Author

martinemde commented May 10, 2024

I just pulled and then ran rake. We were helping people get set up to hack on rubygems at RailsConf and multiple people on OSX with fresh copies of the repo had this happen. My copy was not fresh but this error started happening recently. Probably it's slightly older rubygems on my laptop with Bundler edge.

I pushed this up to unblock people quickly so they could build off this branch. I'm not certain it's the right fix.

Edit: the idea of completely merging bundler into rubygems makes sense in principle and seems like a lot of work. The primary obstacle I see is locked bundler version auto-install.

@deivid-rodriguez
Copy link
Contributor

I think the better fix is to require bundler/shared_helpers in bundler/lib/bundler/rubygems_ext.rb, right before it's used.

I was expecting Bundler::SharedHelpers be autoloaded, not sure why it's happening but at least adding the require right before usage is more explainable.

By the way, sorry for the bad timing of this regression! I wish we had found it before Rails Conf!

@deivid-rodriguez
Copy link
Contributor

deivid-rodriguez commented May 10, 2024

I figured it out. It's unrelated to the version of RubyGems and/or Ruby. It can be reproduced regardless of those by having two different versions of psych installed. If this is the case, the RubyGems require logic that runs to resolve the proper psych version to activate will end up using the monkeypatched StubSpecification functionality before the SharedHelpers autoload in Bundler has the chance to be setup.

@deivid-rodriguez
Copy link
Contributor

I'll open a separate PR for this 👍.

@deivid-rodriguez
Copy link
Contributor

I added what I think it's a better fix at #7647.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants