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
|
If any version of each formula argument is installed and no other options
|
||||||
are passed, this command displays their actual runtime dependencies (similar
|
are passed, this command displays their actual runtime dependencies (similar
|
||||||
to `brew linkage`), which may differ from the current versions' stated
|
to `brew linkage`), which may differ from a formula's declared dependencies.
|
||||||
dependencies if the installed versions are outdated.
|
|
||||||
|
|
||||||
*Note:* `--missing` and `--skip-recommended` have precedence over `--include-*`.
|
*Note:* `--missing` and `--skip-recommended` have precedence over `--include-*`.
|
||||||
EOS
|
EOS
|
||||||
@ -97,21 +96,45 @@ module Homebrew
|
|||||||
Formulary.enable_factory_cache!
|
Formulary.enable_factory_cache!
|
||||||
|
|
||||||
SimulateSystem.with(os:, arch:) do
|
SimulateSystem.with(os:, arch:) do
|
||||||
recursive = !args.direct?
|
@use_runtime_dependencies = true
|
||||||
installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?)
|
|
||||||
|
|
||||||
@use_runtime_dependencies = installed && recursive &&
|
installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?)
|
||||||
!args.tree? &&
|
unless installed
|
||||||
!args.graph? &&
|
not_using_runtime_dependencies_reason = if args.installed?
|
||||||
!args.HEAD? &&
|
"not all the named formulae were installed"
|
||||||
!args.include_implicit? &&
|
else
|
||||||
!args.include_build? &&
|
"`--installed` was not passed"
|
||||||
!args.include_test? &&
|
end
|
||||||
!args.include_optional? &&
|
|
||||||
!args.skip_recommended? &&
|
@use_runtime_dependencies = false
|
||||||
!args.missing? &&
|
end
|
||||||
args.os.nil? &&
|
|
||||||
args.arch.nil?
|
%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?
|
if args.tree? || args.graph?
|
||||||
dependents = if args.named.present?
|
dependents = if args.named.present?
|
||||||
|
@ -37,6 +37,6 @@ RSpec.describe Homebrew::Cmd::Deps do
|
|||||||
expect { brew "deps", "baz", "--include-test", "--missing", "--skip-recommended" }
|
expect { brew "deps", "baz", "--include-test", "--missing", "--skip-recommended" }
|
||||||
.to be_a_success
|
.to be_a_success
|
||||||
.and output("bar\nfoo\ntest\n").to_stdout
|
.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
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user