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

bundle remove does not update lockfile #4889

Closed
indirect opened this issue Aug 31, 2021 · 4 comments · Fixed by #4891
Closed

bundle remove does not update lockfile #4889

indirect opened this issue Aug 31, 2021 · 4 comments · Fixed by #4891

Comments

@indirect
Copy link
Member

indirect commented Aug 31, 2021

Describe the problem as clearly as you can

When using bundle add to add a gem, the lockfile is updated. However, when using bundle remove to take a gem out of the Gemfile, the Gemfile.lock is not updated. I would expect add and remove to by symmetrical, and to both update the lockfile. Instead, I have to run bundle lock after running bundle remove.

Post steps to reproduce the problem

bundle init
cat Gemfile.lock # no rake
bundle add rake
cat Gemfile.lock # rake is now present
bundle remove rake
cat Gemfile.lock # rake is still present (?) ← this is the error state
bundle lock
cat Gemfile.lock # rake no longer present

Which command did you run?

bundle remove rake

What were you expecting to happen?

I expected both Gemfile and Gemfile.lock to be updated to no longer contain rake.

What actually happened?

Only Gemfile was updated.

If not included with the output of your command, run bundle env and paste the output below

Bundler       2.2.21
  Platforms   ruby, universal-darwin-20
Ruby          2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]
  Full Path   /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
  Config Dir  /Library/Ruby/Site
RubyGems      3.0.3
  Gem Home    /Library/Ruby/Gems/2.6.0
  Gem Path    /Users/andre/.gem/ruby/2.6.0:/Library/Ruby/Gems/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
  User Home   /Users/andre
  User Path   /Users/andre/.gem/ruby/2.6.0
  Bin Dir     /usr/local/bin
Tools         
  Git         2.30.1
  RVM         not installed
  rbenv       not installed
  chruby      0.3.9

Bundler Build Metadata

Built At          2021-06-23
Git SHA           0b5db72094

Bundler config

gem.changelog
  Set for the current user (/Users/andre/.bundle/config): true
gem.ci
  Set for the current user (/Users/andre/.bundle/config): "github"
gem.coc
  Set for the current user (/Users/andre/.bundle/config): true
gem.mit
  Set for the current user (/Users/andre/.bundle/config): true
gem.rubocop
  Set for the current user (/Users/andre/.bundle/config): "true"
gem.test
  Set for the current user (/Users/andre/.bundle/config): "rspec"
path
  Set for the current user (/Users/andre/.bundle/config): ".bundle"
@deivid-rodriguez
Copy link
Member

Apparently this is intentional and the way to also update the lockfile is to use bundle remove --install.

BUNDLE-REMOVE(1)                                                                                                                                                                                                        BUNDLE-REMOVE(1)

NAME
       bundle-remove - Removes gems from the Gemfile

SYNOPSIS
       bundle remove [GEM [GEM ...]] [--install]

DESCRIPTION
       Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If a gem cannot be removed, a warning is printed. If a gem is already absent from the Gemfile, and error is raised.

OPTIONS
       --install
              Runs bundle install after the given gems have been removed from the Gemfile, which ensures that both the lockfile and the installed gems on disk are also updated to remove the given gem(s).

       Example:

       bundle remove rails

       bundle remove rails rack

       bundle remove rails rack --install

I don't know why this is optional, to be honest. It should be the default and only behavior in my opinion.

@indirect
Copy link
Member Author

I agree it should be the default, especially since add automatically updates the lockfile. :)

@ceritium
Copy link
Contributor

@indirect, it means to remove the --install option, isn't it? Do you think that adding the--no-install option makes sense?

@indirect
Copy link
Member Author

@ceritium yes, it means removing the --install option, and turning it on all the time. I don't think we need a --no-install option, if you don't want the lockfile updated you can just edit the Gemfile and not run any Bundler commands.

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

Successfully merging a pull request may close this issue.

3 participants