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

Only remove bundler plugin gem when it's inside the cache #7001

Conversation

ccutrer
Copy link
Contributor

@ccutrer ccutrer commented Sep 25, 2023

Fixes #6953

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

A plugin installed with a local path (i.e. via #6960) would completely remove the external gem when you run bundle plugin uninstall.

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

Ensure that any paths are within the plugin root before removing.

Make sure the following tasks are checked

@ccutrer
Copy link
Contributor Author

ccutrer commented Sep 26, 2023

Can you retry the actions? It looks like they failed due to intermittent network issues trying to reach rubygems.org.

@deivid-rodriguez
Copy link
Member

I retried but it still failed. Does the new spec run fine for you locally?

@ccutrer
Copy link
Contributor Author

ccutrer commented Sep 27, 2023

Yes, the new spec runs fine for me on Mac, Ruby 3.1. The failures in GitHub Actions are for specs completely unrelated to plugins.

@deivid-rodriguez
Copy link
Member

I'm seeing this, which is the spec you added here, right?

       Invoking `/Users/runner/hostedtoolcache/Ruby/3.2.1/x64/bin/ruby -I/Users/runner/work/rubygems/rubygems/bundler/spec -r/Users/runner/work/rubygems/rubygems/bundler/spec/support/artifice/fail.rb -r/Users/runner/work/rubygems/rubygems/bundler/spec/support/hax.rb /Users/runner/work/rubygems/rubygems/bundler/tmp/1/gems/system/bin/bundle plugin install path_plugin --path /Users/runner/work/rubygems/rubygems/bundler/tmp/1/libs/path_plugin-1.0` failed with output:
       ----------------------------------------------------------------------
       Could not reach host index.rubygems.org. Check your network connection and try again.
       ----------------------------------------------------------------------
     # ./spec/support/helpers.rb:202:in `sys_exec'
     # ./spec/support/helpers.rb:121:in `bundle'
     # ./spec/plugins/uninstall_spec.rb:39:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:102:in `block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:102:in `block (3 levels) in <top (required)>'
     # ./spec/support/helpers.rb:357:in `block in with_gem_path_as'
     # ./spec/support/helpers.rb:371:in `without_env_side_effects'
     # ./spec/support/helpers.rb:352:in `with_gem_path_as'
     # ./spec/spec_helper.rb:101:in `block (2 levels) in <top (required)>'

Finished in 45 minutes 24 seconds (files took 1.67 seconds to load)
3411 examples, 1 failure, 16 pending

Failed examples:

rspec ./spec/plugins/uninstall_spec.rb:33 # bundler plugin uninstall doesn't wipe out path plugins

@ccutrer
Copy link
Contributor Author

ccutrer commented Sep 27, 2023

Oh man, I apologize. I was reading the output wrong. Yes, that's my new spec. I was seeing the gem generate index in the log and was thinking it was for a spec having to do with that (combined with scrolling too far past all the pending specs). I'll dig in. Probably an inadvertent network access.

@ccutrer
Copy link
Contributor Author

ccutrer commented Sep 27, 2023

Ohhhhhh.... that's why. The spec uses bundle install plugin <plugin> --path <path>, which doesn't exist yet. That's why I had this commit as part of #6960. So the path argument is ignored, and it's trying to find that plugin on Rubygems. If #6960 is merged first, I can rebase this one and then it will work.

@deivid-rodriguez
Copy link
Member

Aaaah right, that makes sense!

bundler/lib/bundler/plugin.rb Outdated Show resolved Hide resolved
@deivid-rodriguez
Copy link
Member

Should we instead change the spec here to use plugin "my_plugin", path: "../my_plugin" in a Gemfile, like in the linked issue, so that this fix is not blocked on the addition of the --path flag to bundle plugin install?

@ccutrer ccutrer force-pushed the bundler-avoid-clobbering-non-vendored-plugins branch from 3831234 to 8d51390 Compare October 30, 2023 17:31
@deivid-rodriguez
Copy link
Member

Looks great, I'll try to merge & release this fix this week!

@deivid-rodriguez deivid-rodriguez merged commit 413386b into rubygems:master Oct 31, 2023
92 checks passed
deivid-rodriguez added a commit that referenced this pull request Nov 8, 2023
…ndored-plugins

Only remove bundler plugin gem when it's inside the cache

(cherry picked from commit 413386b)
deivid-rodriguez added a commit that referenced this pull request Nov 8, 2023
…ndored-plugins

Only remove bundler plugin gem when it's inside the cache

(cherry picked from commit 413386b)
deivid-rodriguez added a commit that referenced this pull request Nov 8, 2023
…ndored-plugins

Only remove bundler plugin gem when it's inside the cache

(cherry picked from commit 413386b)
deivid-rodriguez added a commit that referenced this pull request Nov 8, 2023
…ndored-plugins

Only remove bundler plugin gem when it's inside the cache

(cherry picked from commit 413386b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bundle plugin uninstall wipes out your code if using a path
3 participants