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

Cannot cleanup user gems #1530

Closed
godfat opened this Issue Mar 3, 2016 · 12 comments

Comments

Projects
None yet
5 participants
@godfat
Contributor

godfat commented Mar 3, 2016

Due to this commit: ec8a3fd
I believe this is a regression from 2.6.0.

You could reproduce this by:

gem install rake -v 10.4.2 --user-install
gem install rake -v 10.4.1 --user-install
gem cleanup rake

Reverting it would restore the behaviour.

@bronzdoc bronzdoc self-assigned this Mar 3, 2016

@bronzdoc

This comment has been minimized.

Show comment
Hide comment
@bronzdoc

bronzdoc Mar 3, 2016

Member

Please provide your gem env

Member

bronzdoc commented Mar 3, 2016

Please provide your gem env

@bronzdoc bronzdoc added the feedback label Mar 3, 2016

@godfat

This comment has been minimized.

Show comment
Hide comment
@godfat

godfat Mar 4, 2016

Contributor

It's pretty standard and I believe you could reproduce it by the above commands. The only thing I added was a line in ~/.gemrc:

gem: --user-install --env-shebang --no-rdoc --no-ri

Which I believe has the same effect as you use --user-install in gem install

Here's the gem env:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.1
  - RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/2.3.0
  - USER INSTALLATION DIRECTORY: /home/godfat/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /home/godfat/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/2.3.0
     - /home/godfat/.gem/ruby/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--user-install --env-shebang --no-rdoc --no-ri"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/godfat/bin
     - /home/godfat/.gem/ruby/2.3.0/bin
     - /home/godfat/.gem/rbx/2.2/bin
     - /home/godfat/.gem/jruby/2.2.0/bin
     - /home/godfat/.cabal/bin
     - /usr/local/bin
     - /usr/local/sbin
     - /usr/lib/hardening-wrapper/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/bin
     - /usr/lib/jvm/default/bin
     - /usr/bin/site_perl
     - /usr/bin/vendor_perl
     - /usr/bin/core_perl
Contributor

godfat commented Mar 4, 2016

It's pretty standard and I believe you could reproduce it by the above commands. The only thing I added was a line in ~/.gemrc:

gem: --user-install --env-shebang --no-rdoc --no-ri

Which I believe has the same effect as you use --user-install in gem install

Here's the gem env:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.1
  - RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/2.3.0
  - USER INSTALLATION DIRECTORY: /home/godfat/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /home/godfat/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/2.3.0
     - /home/godfat/.gem/ruby/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--user-install --env-shebang --no-rdoc --no-ri"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/godfat/bin
     - /home/godfat/.gem/ruby/2.3.0/bin
     - /home/godfat/.gem/rbx/2.2/bin
     - /home/godfat/.gem/jruby/2.2.0/bin
     - /home/godfat/.cabal/bin
     - /usr/local/bin
     - /usr/local/sbin
     - /usr/lib/hardening-wrapper/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/bin
     - /usr/lib/jvm/default/bin
     - /usr/bin/site_perl
     - /usr/bin/vendor_perl
     - /usr/bin/core_perl
@bronzdoc

This comment has been minimized.

Show comment
Hide comment
@bronzdoc

bronzdoc Mar 4, 2016

Member

I just tried to reproduce this and I'm having the same results before and after the patch with user installed gems(not cleaning) and i think that's the expected behaviour of gem cleanup in this scenario.

Description:
    The cleanup command removes old versions of gems from GEM_HOME that are not
    required to meet a dependency.  If a gem is installed elsewhere in GEM_PATH
    the cleanup command won't delete it.

    If no gems are named all gems in GEM_HOME are cleaned.
Member

bronzdoc commented Mar 4, 2016

I just tried to reproduce this and I'm having the same results before and after the patch with user installed gems(not cleaning) and i think that's the expected behaviour of gem cleanup in this scenario.

Description:
    The cleanup command removes old versions of gems from GEM_HOME that are not
    required to meet a dependency.  If a gem is installed elsewhere in GEM_PATH
    the cleanup command won't delete it.

    If no gems are named all gems in GEM_HOME are cleaned.

@bronzdoc bronzdoc removed the feedback label Mar 4, 2016

@godfat

This comment has been minimized.

Show comment
Hide comment
@godfat

godfat Mar 4, 2016

Contributor

Not sure why you can't reproduce this on your side, but I could assure you it would cleanup ~/.gem before 2.6.0 at least on my side (both on my Mac and Linux) and I've been using this for many years.

I don't have any GEM_HOME nor GEM_PATH set on the other hand. All defaults.

Perhaps I am relying on a bug which you fixed, if gem clean never intended to cleanup gems installed via --user-install. But well, why not? I don't quite understand the reason behind that.

If there's no strong reason, I would like to ask we preserve the behaviour, that is it should cleanup gems installed via --user-install.

Contributor

godfat commented Mar 4, 2016

Not sure why you can't reproduce this on your side, but I could assure you it would cleanup ~/.gem before 2.6.0 at least on my side (both on my Mac and Linux) and I've been using this for many years.

I don't have any GEM_HOME nor GEM_PATH set on the other hand. All defaults.

Perhaps I am relying on a bug which you fixed, if gem clean never intended to cleanup gems installed via --user-install. But well, why not? I don't quite understand the reason behind that.

If there's no strong reason, I would like to ask we preserve the behaviour, that is it should cleanup gems installed via --user-install.

@drbrain

This comment has been minimized.

Show comment
Hide comment
@drbrain

drbrain Mar 4, 2016

Member

The install, uninstall and cleanup commands should only work on GEM_HOME so you don't accidentally destroy another "environment" when you didn't mean to. --user-install should change GEM_HOME so it might be that we've been missing proper --user-install behavior for cleanup.

Member

drbrain commented Mar 4, 2016

The install, uninstall and cleanup commands should only work on GEM_HOME so you don't accidentally destroy another "environment" when you didn't mean to. --user-install should change GEM_HOME so it might be that we've been missing proper --user-install behavior for cleanup.

@bronzdoc

This comment has been minimized.

Show comment
Hide comment
@bronzdoc

bronzdoc Mar 4, 2016

Member

Marking this as a feature request so cleanup supports the --user-install flag

Member

bronzdoc commented Mar 4, 2016

Marking this as a feature request so cleanup supports the --user-install flag

@godfat

This comment has been minimized.

Show comment
Hide comment
@godfat

godfat Mar 4, 2016

Contributor

@drbrain Thanks. So I think we agree to have install, uninstall, and cleanup being consistent with --user-install.

@bronzdoc I am not very sure if restoring an old behaviour should be considered a new feature, but as long as we could get this work, I don't mind which term should be used. Thanks for your attention, too.

Contributor

godfat commented Mar 4, 2016

@drbrain Thanks. So I think we agree to have install, uninstall, and cleanup being consistent with --user-install.

@bronzdoc I am not very sure if restoring an old behaviour should be considered a new feature, but as long as we could get this work, I don't mind which term should be used. Thanks for your attention, too.

@jonathonf

This comment has been minimized.

Show comment
Hide comment
@jonathonf

jonathonf Jan 4, 2018

Just in case anyone else finds this when wondering why gem clean stopped working as it used to, the "workaround" is to ensure $GEM_HOME is set to your user's gem path, e.g.:

GEM_HOME=$HOME/.gem/ruby/2.4.0 gem cleanup

Perhaps $GEM_HOME needs to be exported in a shellrc file, though if gem install and gem uninstall use a default value I'm not quite sure why gem cleanup doesn't use the same one...

jonathonf commented Jan 4, 2018

Just in case anyone else finds this when wondering why gem clean stopped working as it used to, the "workaround" is to ensure $GEM_HOME is set to your user's gem path, e.g.:

GEM_HOME=$HOME/.gem/ruby/2.4.0 gem cleanup

Perhaps $GEM_HOME needs to be exported in a shellrc file, though if gem install and gem uninstall use a default value I'm not quite sure why gem cleanup doesn't use the same one...

@godfat

This comment has been minimized.

Show comment
Hide comment
@godfat

godfat Jan 5, 2018

Contributor

@jonathonf Thanks, I was using that workaround for awhile. Lately I wrote this to help me: https://github.com/godfat/gem-compact (p.s. gem compact requires RubyGems 2.7.3+)

So I could just:

gem compact

And it would cleanup all gems in GEM_PATH (which would include user gems)

Contributor

godfat commented Jan 5, 2018

@jonathonf Thanks, I was using that workaround for awhile. Lately I wrote this to help me: https://github.com/godfat/gem-compact (p.s. gem compact requires RubyGems 2.7.3+)

So I could just:

gem compact

And it would cleanup all gems in GEM_PATH (which would include user gems)

bundlerbot added a commit that referenced this issue Jul 20, 2018

Auto merge of #2362 - rubygems:add_cleanup_user_install, r=duckinator
Add --user-install behaviour to cleanup command

# Description:

closes #1530

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
@godfat

This comment has been minimized.

Show comment
Hide comment
@godfat

godfat Jul 21, 2018

Contributor

@bronzdoc Thank you for implementing it! A quick question, would it be implicitly granted if gem: --user-install is set in ~/.gemrc?

Contributor

godfat commented Jul 21, 2018

@bronzdoc Thank you for implementing it! A quick question, would it be implicitly granted if gem: --user-install is set in ~/.gemrc?

@bronzdoc

This comment has been minimized.

Show comment
Hide comment
@bronzdoc

bronzdoc Jul 23, 2018

Member

@godfat it should, but is not... i'm checking into it

you could open a new issue about it, thanks!

Member

bronzdoc commented Jul 23, 2018

@godfat it should, but is not... i'm checking into it

you could open a new issue about it, thanks!

@godfat

This comment has been minimized.

Show comment
Hide comment
@godfat

godfat Jul 23, 2018

Contributor

Thank you, here you are: #2365

Contributor

godfat commented Jul 23, 2018

Thank you, here you are: #2365

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