duncs / clusterssh

Cluster SSH - Cluster Admin Via SSH
https://github.com/duncs/clusterssh/wiki
897 stars 79 forks source link

Build fails because system perl is used #45

Closed eserte closed 8 years ago

eserte commented 8 years ago

While trying to build and test App-ClusterSSH-4.04 with CPAN.pm and a custom perl:

Output from './Build':

Building App-ClusterSSH
Generating: ccon
Can't locate Exception/Class.pm in @INC (@INC contains: /tmpfs/.cpan-build/2015110321/App-ClusterSSH-4.04-__BeMt/bin_PL/../lib/perl5 /tmpfs/.cpan-build/2015110321/App-ClusterSSH-4.04-__BeMt/bin_PL/../lib /tmpfs/.cpan-build/2015110321/App-ClusterSSH-4.04-__BeMt/_build/lib /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /tmpfs/.cpan-build/2015110321/App-ClusterSSH-4.04-__BeMt/bin_PL/../lib/App/ClusterSSH/Base.pm line 17.
BEGIN failed--compilation aborted at /tmpfs/.cpan-build/2015110321/App-ClusterSSH-4.04-__BeMt/bin_PL/../lib/App/ClusterSSH/Base.pm line 17.
Compilation failed in require at (eval 2) line 2.
    ...propagated at /usr/share/perl/5.14/base.pm line 93.
BEGIN failed--compilation aborted at /tmpfs/.cpan-build/2015110321/App-ClusterSSH-4.04-__BeMt/bin_PL/../lib/App/ClusterSSH.pm line 10.
Compilation failed in require at ./ccon line 8.
BEGIN failed--compilation aborted at ./ccon line 8.
Failed to generate pod at bin_PL/_build_docs line 37.
bin_PL/_build_docs failed at /opt/perl-5.18.2t/lib/site_perl/5.18.2/Module/Build/Base.pm line 2930.

The existence of /etc/perl in @INC suggests that somewhere the system perl (i.e. /usr/bin/perl) is used, not the perl currently used in the build. Usually such a problem may be be fixed by using $^X.

duncs commented 8 years ago

I have looked over the scripts and they all use '#!/usr/bin/env perl' except for one test file (which I will correct)

Are you able to provide any more information about where this problem might exist?

eserte commented 8 years ago

Using #!/usr/bin/env perl is not correct in the perl and CPAN world.

Let me explain. There are usually three ways of using a perl interpreter:

In the first two cases, /usr/bin/env perl would work, because the "correct" perl interpreter is in the user's PATH. In the last case, the user may or may not set PATH to the custom path. Because of that, ExtUtils::MakeMaker and Module::Build adjust the shebang of scripts to the correct custom perl path. But this happens only if the shebang in the uninstalled script is specified as "#!perl" or "#!/usr/bin/perl". It does not work for "#!/usr/bin/env perl". There's some discussion in https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/issues/58 whether this should be changed.

For testing, where the scripts to be tested are not installed yet, this has the consequence that either these scripts have to be explicitely called with the correct perl interpreter (i.e. using $^X), or by calling the pre-installed version of the script in blib/script (where the shebang is already corrected). (But note that the 2nd variant may or may not work on Windows)

duncs commented 8 years ago

While I understand what you are saying, that is not the behaviour I see.

I have:

This is the output I got:

dferguson@queeg:~/gitroot/clusterssh$ ./Build 
Building App-ClusterSSH
V=v5.16.3 at bin_PL/_build_docs line 10.
X=/home/dferguson/perl5/perlbrew/perls/perl-5.16.3/bin/perl at bin_PL/_build_docs line 11.
Generating: ccon
Generating: clusterssh_bash_completion.dist
Generating: crsh
Generating: cssh
X=/home/dferguson/perl5/perlbrew/perls/perl-5.16.3/bin/perl at ./cssh line 11.
V=v5.16.3 at ./cssh line 12.
Generating: ctel

This is using this diff:

diff --git a/bin_PL/_build_docs b/bin_PL/_build_docs
index fbad4c0..f9756a9 100755
--- a/bin_PL/_build_docs
+++ b/bin_PL/_build_docs
@@ -7,6 +7,9 @@ use FindBin qw($Bin $Script);

 chdir $Bin || die "Unable to chdir into $Bin: $!";

+warn "V=$^V";
+warn "X=$^X";
+
 my $bindir="$Bin/../bin";

 if(! -d $bindir) {
diff --git a/bin_PL/cssh b/bin_PL/cssh
index 82a9b78..5d47349 100755
--- a/bin_PL/cssh
+++ b/bin_PL/cssh
@@ -7,6 +7,10 @@ use lib $FindBin::Bin. '/../lib';
 use lib $FindBin::Bin. '/../lib/perl5';
 use App::ClusterSSH;

+
+warn "X=$^X";
+warn "V=$^V";
+
 my $app = App::ClusterSSH->new();

 $app->options->add_common_ssh_options;

This shows my perlbrew installation is working as expected and is not using the sytem provided perl while having the 'env perl' shebang in place

Duncs

eserte commented 8 years ago

Actually I said that perlbrew works ("In the first two cases ..."). It's the self-compiled perl (without using perlbrew) which does not work.

If you want to see the problematic behaviour you have to compile your own perl (e.g. using ./configure.gnu --prefix=/path/to/customperl, not change PATH and then use /path/to/customperl/bin/cpan App::ClusterSSH to see the test failure.

Note that most CPAN Testers don't use perlbrew, so you will then always get fail reports from them.

duncs commented 8 years ago

I have compiled up my own perl, proven the issue exists, fixed it and committed it, and pushed the change to the repo. This will be in released 4.04_01.

Thanks for the bug report.