mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
cmd/deps: add warning when not using runtime dependencies.
This should provide clarify as to why the output may differ from a formula's declared dependencies.
This commit is contained in:
parent
3c9a7332d4
commit
d2f9677cde
@ -18,8 +18,7 @@ module Homebrew
|
||||
|
||||
If any version of each formula argument is installed and no other options
|
||||
are passed, this command displays their actual runtime dependencies (similar
|
||||
to `brew linkage`), which may differ from the current versions' stated
|
||||
dependencies if the installed versions are outdated.
|
||||
to `brew linkage`), which may differ from a formula's declared dependencies.
|
||||
|
||||
*Note:* `--missing` and `--skip-recommended` have precedence over `--include-*`.
|
||||
EOS
|
||||
@ -97,21 +96,45 @@ module Homebrew
|
||||
Formulary.enable_factory_cache!
|
||||
|
||||
SimulateSystem.with(os:, arch:) do
|
||||
recursive = !args.direct?
|
||||
installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?)
|
||||
@use_runtime_dependencies = true
|
||||
|
||||
@use_runtime_dependencies = installed && recursive &&
|
||||
!args.tree? &&
|
||||
!args.graph? &&
|
||||
!args.HEAD? &&
|
||||
!args.include_implicit? &&
|
||||
!args.include_build? &&
|
||||
!args.include_test? &&
|
||||
!args.include_optional? &&
|
||||
!args.skip_recommended? &&
|
||||
!args.missing? &&
|
||||
args.os.nil? &&
|
||||
args.arch.nil?
|
||||
installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?)
|
||||
unless installed
|
||||
not_using_runtime_dependencies_reason = if args.installed?
|
||||
"not all the named formulae were installed"
|
||||
else
|
||||
"`--installed` was not passed"
|
||||
end
|
||||
|
||||
@use_runtime_dependencies = false
|
||||
end
|
||||
|
||||
%w[direct tree graph HEAD skip_recommended missing
|
||||
include_implicit include_build include_test include_optional].each do |arg|
|
||||
next unless args.public_send("#{arg}?")
|
||||
|
||||
not_using_runtime_dependencies_reason = "--#{arg.tr("_", "-")} was passed"
|
||||
|
||||
@use_runtime_dependencies = false
|
||||
end
|
||||
|
||||
%w[os arch].each do |arg|
|
||||
next if args.public_send(arg).nil?
|
||||
|
||||
not_using_runtime_dependencies_reason = "--#{arg.tr("_", "-")} was passed"
|
||||
|
||||
@use_runtime_dependencies = false
|
||||
end
|
||||
|
||||
if !@use_runtime_dependencies && !Homebrew::EnvConfig.no_env_hints?
|
||||
opoo <<~EOS
|
||||
`brew deps` is not the actual runtime dependencies because #{not_using_runtime_dependencies_reason}!
|
||||
This means dependencies may differ from a formula's declared dependencies.
|
||||
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
|
||||
EOS
|
||||
end
|
||||
|
||||
recursive = !args.direct?
|
||||
|
||||
if args.tree? || args.graph?
|
||||
dependents = if args.named.present?
|
||||
|
@ -37,6 +37,6 @@ RSpec.describe Homebrew::Cmd::Deps do
|
||||
expect { brew "deps", "baz", "--include-test", "--missing", "--skip-recommended" }
|
||||
.to be_a_success
|
||||
.and output("bar\nfoo\ntest\n").to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and output(/not the actual runtime dependencies/).to_stderr
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user