diff --git a/lib/Zef/CLI.rakumod b/lib/Zef/CLI.rakumod index 6999086e..f43f2c44 100644 --- a/lib/Zef/CLI.rakumod +++ b/lib/Zef/CLI.rakumod @@ -680,7 +680,7 @@ package Zef::CLI { !! (my $uri = uri($wanted) and !$uri.is-relative) ?? !! abort("Don't understand identity: {$wanted}"); } - my $client = Zef::Client.new(:config($CONFIG), :$depends, :$test-depends, :$build-depends,); + my $client = Zef::Client.new(:config($CONFIG), :$depends, :$test-depends, :$build-depends, :force-resolve); abort "The following were recognized as file paths but don't exist as such - {@paths.grep(!*.IO.e)}" if +@paths.grep(!*.IO.e); @@ -711,7 +711,7 @@ package Zef::CLI { Bool :$test-depends = True, Bool :$build-depends = True, ) { - my $client = get-client(:config($CONFIG), :$depends, :$test-depends, :$build-depends); + my $client = get-client(:config($CONFIG), :$depends, :$test-depends, :$build-depends, :force-resolve); .dist.identity.say for $client.list-rev-depends($identity); exit 0; } diff --git a/lib/Zef/Client.rakumod b/lib/Zef/Client.rakumod index 2acd8ad4..0cd5a830 100644 --- a/lib/Zef/Client.rakumod +++ b/lib/Zef/Client.rakumod @@ -465,19 +465,39 @@ class Zef::Client { message => "Failed to find dependencies: {@not-found.map(*.identity).join(', ')}", }); - $!force-resolve - ?? $!logger.emit({ - level => ERROR, - stage => RESOLVE, - phase => LIVE, - message => 'Failed to resolve missing dependencies, but continuing with --force-resolve', + if $!force-resolve { + $!logger.emit({ + level => ERROR, + stage => RESOLVE, + phase => LIVE, + message => 'Failed to resolve missing dependencies, but continuing with --force-resolve', + }); + + # When using force-resolve we still want to treat the missing dependency as if it exists. + # This is intended to allow `zef depends XXX` to show dependencies for e.g. native dependencies + # where we don't have to worry about not finding their transitive dependencies. + @prereq-candidates.append( + @not-found.map({ + Candidate.new( + as => $_.identity, + dist => Zef::Distribution.new( + name => $_.name, + auth => $_.auth-matcher, + ver => $_.version-matcher, + api => $_.api-matcher, + ), + ) }) - !! die X::Zef::UnsatisfiableDependency.new but role :: { + ) + } + else { + die X::Zef::UnsatisfiableDependency.new but role :: { method message { X::Zef::UnsatisfiableDependency.message ~ qq| (use e.g. --exclude="{@not-found.head.name}" to skip)|; } }; - }; + } + } @skip.append: @prereq-candidates.map(*.dist); @specs = self.list-dependencies(@prereq-candidates);