Skip to content

Conversation

@eregon
Copy link
Member

@eregon eregon commented Dec 5, 2025

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

From https://github.com/ruby/rubygems/pull/9136/files#r2592366837

The suggestion of bundle config set default_cli_command install_or_cli_help --global is bad because it breaks on Bundler 2:

$ ruby --version
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]
$ bundle --version     
Bundler version 2.4.19
$ bundle
Could not find command "".
zsh: exit 15    bundle

So the suggestion should be install and not install_or_cli_help.
And the install command can have that help behavior on missing gemfile, it's fine and simple.

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

Make the behavior of install_or_cli_help part of install and suggest to config install as the default command in that warning, because install always existed, while install_or_cli_help is only in Bundler 4.

Make sure the following tasks are checked

@eregon eregon force-pushed the fix-broken-config-recommendation-in-default-command-warning branch from 41fadbe to 8395b28 Compare December 5, 2025 12:13

### Bug fixes:

- Fix the suggestion in the warning for the default `bundle` command [#9164](https://github.com/ruby/rubygems/pull/9164)
Copy link
Member

@hsbt hsbt Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this. It will handle by release script automatically.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

end

desc "install_or_cli_help", "Tries to run bundle install but prints a summary of bundler commands if there is no Gemfile", hide: true
def install_or_cli_help
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this task and warn to suggest update default_cli_command to install.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* `install_or_cli_help` does not exist for older Bundler like Bundler 2
  and so results in a confusing error on Bundler 2:
  ```
  $ bundle
  Could not find command "".
  ```
* See https://github.com/ruby/rubygems/pull/9136/files#r2592366837
* Merge the behavior of `install_or_cli_help` in `install`.
* It looked like:
            In a future version of Bundler, running `bundle` without argument will no longer run `bundle install`.
            Instead, the `cli_help` command will be displayed. Please use `bundle install` explicitly for scripts like CI/CD.
            You can use the future behavior now with `bundle config set default_cli_command cli_help --global`,
            or you can continue to use the current behavior with `bundle config set default_cli_command install --global`.
            This message will be removed after a default_cli_command value is set.
  Bundler version 4.0.0 (2025-12-08 commit 9b4819a)
* And now looks like:
  In a future version of Bundler, running `bundle` without argument will no longer run `bundle install`.
  Instead, the `cli_help` command will be displayed. Please use `bundle install` explicitly for scripts like CI/CD.
  You can use the future behavior now with `bundle config set default_cli_command cli_help --global`,
  or you can continue to use the current behavior with `bundle config set default_cli_command install --global`.
  This message will be removed after a default_cli_command value is set.

  Bundler version 4.0.0 (2025-12-08 commit 9b4819a)
@eregon eregon force-pushed the fix-broken-config-recommendation-in-default-command-warning branch from 8395b28 to 979dada Compare December 8, 2025 11:25
@eregon
Copy link
Member Author

eregon commented Dec 8, 2025

All done, BTW I noticed the info message for default_cli_command was using <<-MSG and as a result had lots of indentation and fixed that too:

* It looked like:
          In a future version of Bundler, running `bundle` without argument will no longer run `bundle install`.
          Instead, the `cli_help` command will be displayed. Please use `bundle install` explicitly for scripts like CI/CD.
          You can use the future behavior now with `bundle config set default_cli_command cli_help --global`,
          or you can continue to use the current behavior with `bundle config set default_cli_command install --global`.
          This message will be removed after a default_cli_command value is set.
Bundler version 4.0.0 (2025-12-08 commit 9b4819ae18)
* And now looks like:
In a future version of Bundler, running `bundle` without argument will no longer run `bundle install`.
Instead, the `cli_help` command will be displayed. Please use `bundle install` explicitly for scripts like CI/CD.
You can use the future behavior now with `bundle config set default_cli_command cli_help --global`,
or you can continue to use the current behavior with `bundle config set default_cli_command install --global`.
This message will be removed after a default_cli_command value is set.

Bundler version 4.0.0 (2025-12-08 commit 9b4819ae18)

@eregon eregon requested a review from hsbt December 8, 2025 11:30
@hsbt
Copy link
Member

hsbt commented Dec 9, 2025

I could reproduce this.

❯ bundle config set default_cli_command install_or_cli_help --global
You are replacing the current global value of default_cli_command, which is currently "cli_help"
❯ bundle _2.3.7_
Could not find command "".

I would like to keep install_or_cli_help in the future. But I also don't want to break the released version of Bundler.

Thank you for suggesting this.

@hsbt hsbt merged commit 03e3b78 into ruby:master Dec 9, 2025
81 checks passed
hsbt added a commit that referenced this pull request Dec 9, 2025
…-in-default-command-warning

Fix the config suggestion in the warning for `$ bundle`

(cherry picked from commit 03e3b78)
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.

2 participants