Skip to content

Fix generator issues with newer rubygems and bundler#9849

Closed
ahukkanen wants to merge 21 commits intodecidim:developfrom
mainio:fix/modern-rubygems-executable-issues
Closed

Fix generator issues with newer rubygems and bundler#9849
ahukkanen wants to merge 21 commits intodecidim:developfrom
mainio:fix/modern-rubygems-executable-issues

Conversation

@ahukkanen
Copy link
Copy Markdown
Contributor

@ahukkanen ahukkanen commented Sep 22, 2022

🎩 What? Why?

With rubygems 3.3.x which ships with bundler 2.3.x we have currently issues using the decidim generators or actually any executables we provide (which is generally the decidim executable).

My assumption is that the key feature related to this issue that was added in the newer version of bundler is that it recognizes the bundler version based on the Gemfile.lock and installs that particular bundler version in case it was not already installed and installs the gems under that bundler version.

Apparently this approach has still some problems as the bundler versions get mixed. If you only have one version of bundler installed, there is no problem running the decidim executables but if you have more than one version (2.3.x with an older version such as 2.2.x), this issue appears.

To fix this issue, I am proposing that we remove the automatic copying of the Gemfile.lock files into the newly generated Decidim application to get around this issue. Let's just let bundler generate the Gemfile.lock locally.

In fact, I don't even understand why we wanted to do this in the first place so if anyone has an idea why this is done, feel free to enlighten me.

As an extra, we can finally get rid of these messages (showed up after Ruby 3.1 upgrade) in the console once this is merged:

Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.

📌 Related Issues

Testing

See the replication instructions from #9839.

Also, see that the CI is green. We have many failing build examples e.g. at #9766 where I tried to initially update the bundler to newer one but I believe it failed because of this same reason.

@ahukkanen ahukkanen marked this pull request as draft September 22, 2022 10:31
@ahukkanen
Copy link
Copy Markdown
Contributor Author

It seems that I still have exactly the same problems that I had at #9766, so marking this as draft for now until investigating further.

Bottom line is that my initial assumption seems incorrect.

@ahukkanen
Copy link
Copy Markdown
Contributor Author

Tested this also locally and the proposed fix would actually solve #9839 but now the problem is with the generators spec, which are also broken if you run them locally under the same conditions.

This is something I haven't figured out yet...

@ahukkanen
Copy link
Copy Markdown
Contributor Author

Note to myself regarding that last CI problem:

The problem seems to be if the gem environment already has different versions of some gems required what Decidim requires. In the particular case that I was debugging I found out that:

So the solution to this would be to always have exactly the same versions of gems installed as are loaded to RubyGems.

I need to investigate a bit further what is causing the version mis-match, i.e. is it the same rack gem at the CI as locally on my machine and what is causing the different version of that gem to be already installed when interpreting the Decidim requirements.

@andreslucena
Copy link
Copy Markdown
Member

@ahukkanen can you merge with develop and also update the bundler version from 2.3.7 to 2.3.25 🙏🏽 ?

@andreslucena
Copy link
Copy Markdown
Member

andreslucena commented Nov 10, 2022

I mentioned it on our internal chat, but I think that is good to also leave it here for the people from the future:

The error that we're seeing (uninitialized constant Gem::BundlerVersionFinder exception) was already present on Decidim for these specs. Examples: #3654 (comment) #3532 (comment)

It was solved on rubygems ruby/rubygems#2196. My hypothesis on why it broke again is because they started removing these kinds of requires as there was an autoload related bug on JRuby ruby/rubygems#3751. They mention that these shouldn't be necessary, but maybe something that we're doing in the specs/generator produces a change in the Bundler/rubygems autoload?

I didn't have the chance (yet) to try out if the naive solution (adding again the requires on the necessary files in my local installation) could solve this issue, but when I have time I'd want to try that.

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

For what it's worth, we got this problem reported at ruby/rubygems#6145 and I plan to ship the fix with RubyGems 3.4.0 next week.

@andreslucena
Copy link
Copy Markdown
Member

Awesome @deivid-rodriguez, thank you very much!

We didn't have time to allocate to this issue, and couldn't pinpoint exactly the reason why this was happening and make a proof of concept to report to rubygems. Thank you for letting it us know.

We'll keep track of that issue and let you know if we have any problem with the fix once its released.

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

No problem! I don't really know why it's happening either, a Ruby bug I guess. But the workaround for us is easy :)

Keep up the good work!

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

RubyGems 3.4.0 is out now with this fix. Happy holidays! :)

@ahukkanen
Copy link
Copy Markdown
Contributor Author

Thanks for the fix @deivid-rodriguez, really nice Christmas gift from you!

Turns out we had a bug in Decidim that I submitted a new PR for #10220.

But your fix made it way easier to debug and fix the problem as the stacktrace made sense all of a sudden after upgrading RubyGems and Bundler.

I will try upgrading RubyGems again after we have merged #10220.

Happy new year!

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

Awesome, really glad our releases made things easier! Keep up the good work 💪

@ahukkanen
Copy link
Copy Markdown
Contributor Author

Superseded by #10323.

Closing this one.

@ahukkanen ahukkanen closed this Feb 1, 2023
@ahukkanen ahukkanen deleted the fix/modern-rubygems-executable-issues branch February 1, 2023 09:58
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.

Uninitialized constant Gem::BundlerVersionFinder error during gem generation

3 participants