From a127d22457f11e67aab623b22fa19add83da598f Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 18 Feb 2012 20:12:14 +0000 Subject: [PATCH] Improve error message when package is not found. --- NEWS | 6 ++++++ lib/Stow.pm.in | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 4ccd179..2f4f87e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,12 @@ News file for Stow. * Changes in version 2.1.4 +** Improve error message when stow package is not found. + + The error message displayed a path to the missing stow package + which was relative to the target directory rather than the cwd, + which was confusing for the user. + ** Test suite improvements The test suite has been tightened up slightly. diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4479b6a..7ef1828 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -248,8 +248,9 @@ sub plan_unstow { $self->within_target_do(sub { for my $package (@packages) { - if (not -d join_paths($self->{stow_path}, $package)) { - error("The stow directory $self->{dir} does not contain package $package"); + my $path = join_paths($self->{stow_path}, $package); + if (not -d $path) { + error("The stow directory $self->{stow_path} does not contain package $package"); } debug(2, "Planning unstow of package $package..."); if ($self->{compat}) { @@ -286,15 +287,16 @@ sub plan_stow { $self->within_target_do(sub { for my $package (@packages) { - if (not -d join_paths($self->{stow_path}, $package)) { - error("The stow directory $self->{dir} does not contain package $package"); + my $path = join_paths($self->{stow_path}, $package); + if (not -d $path) { + error("The stow directory $self->{stow_path} does not contain package $package"); } debug(2, "Planning stow of package $package..."); $self->stow_contents( $self->{stow_path}, $package, '.', - join_paths($self->{stow_path}, $package), # source from target + $path, # source from target ); debug(2, "Planning stow of package $package... done"); $self->{action_count}++;