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

--quiet conflicts with HOMEBREW_VERBOSE for brew-outdated #5736

Closed
zmwangx opened this issue Feb 14, 2019 · 6 comments
Closed

--quiet conflicts with HOMEBREW_VERBOSE for brew-outdated #5736

zmwangx opened this issue Feb 14, 2019 · 6 comments
Labels
outdated PR was locked due to age

Comments

@zmwangx
Copy link
Contributor

zmwangx commented Feb 14, 2019

I have HOMEBREW_VERBOSE set for many years, and it never conflicted with the --quiet flag on the command line. When --quiet is specified, it simply overrides HOMEBREW_VERBOSE, as is the convention for handling option vs environment variable in most *nix tools.

However, a few weeks ago, 867b155 (CC author @MikeMcQuaid) broke this. Now, using --quiet with brew outdated when HOMEBREW_VERBOSE is set simply results in an error saying --quiet and --verbose are mutually exclusive. (This broke my auto update script.) The problem apparently stems from making no distinction between HOMEBREW_VERBOSE and the --verbose option on the command line.

The point is: command line option should override a conflicting env var when necessary, instead of being treated as a conflicting equal.

What you were trying to do (and why)

$ HOMEBREW_VERBOSE=1 brew outdated --quiet

Why? Because I have HOMEBREW_VERBOSE set globally, and only override it on the command line as I see fit.

What happened

$ HOMEBREW_VERBOSE=1 brew outdated --quiet
Error: Options --quiet and --verbose are mutually exclusive.

What you expected to happen

No error.

P.S. The help text doesn't help.

$ brew outdated -h
Usage: brew outdated [options]

Show formulae that have an updated version available.

By default, version information is displayed in interactive shells, and
suppressed otherwise.

    -q, --quiet                      List only the names of outdated brews
                                     (takes precedence over --verbose).

Note takes precedence over.

@RandomDSdevel
Copy link
Contributor

     This was fixed in #5738.

@zmwangx
Copy link
Contributor Author

zmwangx commented Feb 25, 2019

Pretty sure it's not.

@MikeMcQuaid
Copy link
Member

@zmwangx Will reopen when you confirm/paste current error, thanks.

@zmwangx
Copy link
Contributor Author

zmwangx commented Feb 25, 2019

Well, just the same?

Unsetting all HOMEBREW_* env vars to make sure:

$ brew config
HOMEBREW_VERSION: 2.0.2-78-g59aac33-dirty
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 59aac3347acf83e2b7950b8cb20df2b92986f4ec
Last commit: 24 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 5586214830894b3b84be367aa40d855cb7392d4c
Core tap last commit: 3 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_BINTRAY_KEY: set
HOMEBREW_BINTRAY_USER: zmwangx
HOMEBREW_DEV_CMD_RUN: 1
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.d8XS1wCxxE/org.macosforge.xquartz:0
HOMEBREW_LOGS: /Users/zmwang/Library/Logs/Homebrew
HOMEBREW_VISUAL: /Users/zmwang/scripts/editor
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1000
Git: 2.21.0 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 9.0.1
macOS: 10.14.3-x86_64
CLT: 10.1.0.0.1.1539992718
Xcode: 10.1
XQuartz: 2.7.11 => /opt/X11
$ HOMEBREW_VERBOSE=1 brew outdated --quiet --debug
Error: Options --quiet and --verbose are mutually exclusive.
/usr/local/Homebrew/Library/Homebrew/cli_parser.rb:241:in `block in check_conflicts'
/usr/local/Homebrew/Library/Homebrew/cli_parser.rb:229:in `each'
/usr/local/Homebrew/Library/Homebrew/cli_parser.rb:229:in `check_conflicts'
/usr/local/Homebrew/Library/Homebrew/cli_parser.rb:259:in `check_constraint_violations'
/usr/local/Homebrew/Library/Homebrew/cli_parser.rb:135:in `parse'
/usr/local/Homebrew/Library/Homebrew/cmd/outdated.rb:35:in `outdated'
/usr/local/Homebrew/Library/Homebrew/brew.rb:102:in `<main>'

Haven't looked at the code.

@zmwangx
Copy link
Contributor Author

zmwangx commented Feb 25, 2019

Okay, looked at the code, found the bug:

env_var_options = violations.select do |option|
@switch_sources[option_to_name(option)] == :env_var
end

Looks like :env_var should be :env.

Also commented on the original PR.

@MikeMcQuaid
Copy link
Member

Thanks @zmwangx!

@MikeMcQuaid MikeMcQuaid reopened this Feb 25, 2019
@lock lock bot added the outdated PR was locked due to age label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

3 participants