Skip to content
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

https://github.com/rubygems/rubygems/issues/5289 #105

Closed
uhuntu opened this issue Oct 29, 2022 · 9 comments
Closed

https://github.com/rubygems/rubygems/issues/5289 #105

uhuntu opened this issue Oct 29, 2022 · 9 comments

Comments

@uhuntu
Copy link

uhuntu commented Oct 29, 2022

Hello there, can some one help to explain this: rubygems/rubygems#5289

It is pretty strange.

I had followed this line: https://bundler.io/guides/creating_gem.html to start the scratch the gem making, but lastly he said you should install a plugin to bump release, then I follow, after that strange thing happen.

-> % bundle exec rake release
foodie_hunt 1.1.1 built to pkg/foodie_hunt-1.1.1.gem.
Tag v1.1.1 has already been created.
Error loading RubyGems plugin "/usr/share/rvm/gems/ruby-3.1.2/plugins/gem-release_plugin.rb": cannot load such file -- gem/release (LoadError)
Pushing gem to https://rubygems.org...
Repushing of gem versions is not allowed.
Please bump the version number and push a new different release.
See also `gem yank` if you want to unpublish the bad release.

You can see that there is a line:

Error loading RubyGems plugin "/usr/share/rvm/gems/ruby-3.1.2/plugins/gem-release_plugin.rb": cannot load such file -- gem/release (LoadError)

Then I used the google machine to reach how it is happening, the I found here: rubygems/rubygems#5289
Some ones also were struggling on this issue.

@PikachuEXE
Copy link
Collaborator

Try this first?
rubygems/rubygems#5289 (comment)

@uhuntu
Copy link
Author

uhuntu commented Oct 30, 2022

Yeah you are smart.

@pboling
Copy link
Contributor

pboling commented Oct 25, 2024

@svenfuchs I think this should be reopened. It is a legitimate bug.

Lots of plugins use the gem gem-release, which isn't part of bundler / rubygems, but appears to conflict in load paths, resulting in this error.

If you use a global Ruby for multiple projects (as you often do with any type of ruby version manager), some gems or apps will depend on the gem-release, while other won't, and thus it will be installed and within reach of gem's load paths.

Then when you do a canonical bundle exec rake release using the standard gem tasks, in a project that does not depend on gem-release, but within a Ruby environment that has it installed, it will mistakenly hit that load path.

You can see that is exactly what happened in the paths @jrochkind saw:

/Users/jrochkind/.gem/ruby/3.0.4/gems/gem-release-2.2.2/lib/rubygems_plugin.rb

I just had the same issue. I am not sure which library depended on it, but there are 2 potential (and sort of temporary) solutions.

  1. Add as a dependency: bundle add gem-release
    a. Will work until attempting to release another library which doesn't declare it as a dependency.
  2. Uninstall globally from Ruby:gem uninstall gem-release
    a. Will work until the library that depends on it is installed again.

@jrochkind
Copy link

Oh interesting. I don't expect gems that are installed systemwide but NOT in my bundle to affect my bundle, since Bundler is normally so good about that. That's unfortunate.

@tvdeyen
Copy link

tvdeyen commented Dec 19, 2024

I can validate this is fixed by #111 and

gem install gem-release -v '2.2.3.alpha4'

@pboling
Copy link
Contributor

pboling commented Dec 19, 2024

@jrochkind The solution, for all Ruby gem libraries, is to use require_relative to load internal lib files.

See rubocop/rubocop#8748 (comment)

@jrochkind
Copy link

@pboling interesting, I think that's definitely not yet widely known! i have written many gems that don't do that, unfortunately.

If someone wanted to write up this guidance with clear explanation of motivation/why (I am not entirely following myself), that would def be a service to the community! If such already exists somewehre that is great! Perhaps it should be on some kind of "official" site somewhere to have credibility and attention.

@pboling
Copy link
Contributor

pboling commented Dec 19, 2024

I plan to work on that, somewhere on my todo list image

@PikachuEXE
Copy link
Collaborator

Fix released in https://rubygems.org/gems/gem-release/versions/2.2.3

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

No branches or pull requests

5 participants