Skip to content

Commit

Permalink
Merge pull request #578 from ugexe/issue-517
Browse files Browse the repository at this point in the history
Improve force-resolve behavior to accomodate `zef depends ...`
  • Loading branch information
ugexe authored Nov 29, 2024
2 parents a103ae4 + be9a186 commit 755d931
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/Zef/CLI.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ package Zef::CLI {
!! (my $uri = uri($wanted) and !$uri.is-relative) ?? <uris>
!! 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);
Expand Down Expand Up @@ -733,7 +733,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;
}
Expand Down
36 changes: 28 additions & 8 deletions lib/Zef/Client.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -467,19 +467,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);
Expand Down

0 comments on commit 755d931

Please sign in to comment.