Bug 1039356 - Perl Module Dependency - Local vs. CPAN
Summary: Perl Module Dependency - Local vs. CPAN
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Image
Version: 2.x
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: ---
: ---
Assignee: Michal Fojtik
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks: 1157767
TreeView+ depends on / blocked
 
Reported: 2013-12-08 17:33 UTC by ben.sommer
Modified: 2019-03-22 07:09 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1157767 (view as bug list)
Environment:
Last Closed: 2015-02-18 16:49:59 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description ben.sommer 2013-12-08 17:33:13 UTC
Description of problem:

Hi - my perl build process (perl/bin/build) is failing when it comes to a local module (Donation.pm) from my application. It apparently thinks that it should exist on CPAN (which it doesn't):

! Finding Donation on cpanmetadb failed. ! Finding Donation on search.cpan.org failed. ! Finding Donation on mirror http://mirror1.ops.rhcloud.com/mirror/perl/CPAN failed. ! Finding Donation on mirror http://search.cpan.org/CPAN failed. ! Couldn't find module or a distribution Donation

Then the rest of the dependencies fail, and build halts.

I made sure to add my applications module directory to PERL5LIB appropriately:

export PERL5LIB=$PERL5LIB:$HOME/app-root/repo/BulkLoad

How do I tell perl/bin/build to not worry about Donation.pm? This program is not well documented.

How reproducible:

Try running perl build with a custom module in your repo that doesn't exist on CPAN

This comment from someone on the forum may bring a clue:

"I'm not entirely sure if this is answering the exact question that you're having, but for a mini perl app that I deployed, the (non-CPAN and not included in deplist.txt) modules I have living in /libs (from the top-level) seem to have been found and used just fine. I do seem to remember a bit of trial and error getting environment to work correctly locally and deployed though."

Comment 1 Jakub Hadvig 2013-12-09 17:06:54 UTC
Where are you executing the export, it must be exported before the build script is executed so the check in the build script can successfully load that dependency from your folder.

The check in your build script:
https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-perl/bin/build#L38
 
Also could you instead of 'export', include the module like this:
use lib 'Y:/my/dir/to/Donation.pm';

Comment 2 Jakub Hadvig 2013-12-09 18:47:05 UTC
or just: 

use lib 'Y:/my/dir/to';

Comment 3 Jakub Hadvig 2013-12-09 22:09:47 UTC
OK..sorry for that last, figure out that you have to use it like this: 

use lib '/path/dir/to';
use MyCustomModule;

where 'module' is name of the module.

Comment 4 Michal Fojtik 2013-12-16 12:19:16 UTC
Ben, does the solution mentioned by Jakub fixed your problem?

Comment 5 Jakub Hadvig 2013-12-20 14:41:58 UTC
Closing this issue due to no further feedback from the reporter.
Discussed this also with mfojtik and he agreed to close this issue.

Comment 7 Jakub Hadvig 2014-09-10 13:38:38 UTC
So I have tried two approaches to reproduce the issue:

1. Created simpler perl application with rhc:
   rhc app create perl perl-5.10

2. Add the Util module to the index.pl :
   sed -i "2i use Util;" index.pl

3. create the libs directory:
   mkdir -p libs

4. Create Util.pm module with some functionality: 
echo "package Util;
use strict;
use warnings;
use Exporter qw(import);
our @EXPORT_OK = qw(add multiply);
sub add {
    my ($x, $y) = @_;
    return $x + $y;
}
sub multiply {
    my ($x, $y) = @_;
    return $x * $y;
}
1;" >> libs/Util.pm 


I even tried to put the Util.pm into /libs/Lieder/ directory, just to be sure it is working even if the module is nested.
In both cases the result was the same:

remote: Building Perl cartridge
remote: ***  Installing modules from .openshift/cpan.txt
remote: ***   Skipping module Exporter install from CPAN (found in system).
remote: ***   Please add Exporter to .openshift/cpan.txt to install it from CPAN.
remote: ***  Skipping module Util install from CPAN (found locally).
remote: ***  Please add Util to .openshift/cpan.txt to install it from CPAN.
remote: ***   Skipping module strict install from CPAN (found in system).
remote: ***   Please add strict to .openshift/cpan.txt to install it from CPAN.
remote: ***   Skipping module warnings install from CPAN (found in system).
remote: ***   Please add warnings to .openshift/cpan.txt to install it from CPAN.

so the modules where found.

Comment 10 Michal Fojtik 2014-10-20 12:05:07 UTC
Guy, can you please help review this PR?

https://github.com/openshift/origin-server/pull/5888

Comment 12 Jon Thomas 2014-12-04 18:21:46 UTC
Hi

I followed the exact procedure outlined in #7 using openshift online and it fails with:

remote: Building Perl cartridge
remote: ***  Installing modules from .openshift/cpan.txt
remote: ! Finding Util on cpanmetadb failed.
remote: ! Finding Util () on mirror http://mirror.ops.rhcloud.com/mirror/perl/CPAN failed.
remote: ! Finding Util () on mirror http://search.cpan.org/CPAN failed.
remote: ! Couldn't find module or a distribution Util ()
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/5480a433e0b8cdcd9c000209/perl

if I change the mod name from Util.pm to junk.pm and also to use junk; it works.

Comment 13 Jon Thomas 2014-12-05 21:25:36 UTC
Behavior changes somewhat using ose 2.2. It fails differently and pulls Util out of Parse-Pidl.

$ git push
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 295 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Stopping Perl cartridge
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Building git ref 'master', commit dbb1336
remote: Building Perl cartridge
remote: ***  Installing modules from .openshift/cpan.txt
remote: ! Finding Util on cpanmetadb failed.
remote: --> Working on Util
remote: Fetching http://search.cpan.org/CPAN/authors/id/C/CT/CTRLSOFT/Parse-Pidl-0.02.tar.gz ... OK
remote: Configuring Parse-Pidl-0.02 ... OK
remote: Building Parse-Pidl-0.02 ... OK
remote: Successfully installed Parse-Pidl-0.02
remote: 1 distribution installed
remote: Preparing build for deployment
remote: Deployment id is 5c95333f
remote: Activating deployment
remote: Starting Perl cartridge
remote: Application directory "/" selected as DocumentRoot
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success

Comment 14 openshift-github-bot 2014-12-15 14:13:51 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/867c05ac6cc2509c15d14d1f05a1b7b7eeb23c7e
Bug 1039356 - Skip the failed CPAN modules to allow build to finish

Comment 15 DeShuai Ma 2014-12-16 06:33:11 UTC
Version-Release number of selected component (if applicable):
devenv_5360

Steps to Reproduce:
1. Created simpler perl application with rhc:
   rhc app create perl perl-5.10

2. Add the Util module to the index.pl :
   sed -i "2i use Util;" index.pl

3. create the libs directory:
   mkdir -p libs

4. Create Util.pm module with some functionality: 
echo "package Util;
use strict;
use warnings;
use Exporter qw(import);
our @EXPORT_OK = qw(add multiply);
sub add {
    my ($x, $y) = @_;
    return $x + $y;
}
sub multiply {
    my ($x, $y) = @_;
    return $x * $y;
}
1;" >> libs/Util.pm 

5. Add module "Util","strict","warnings","Exporter" to file ".openshift/cpan.txt"

6.Push the change the application.
# git add ./
# git commit -anmp
[root@dhcp-128-7 perl]# git push
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 333 bytes, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Stopping Perl cartridge
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Building git ref 'master', commit d284837
remote: Building Perl cartridge
remote: ***  Installing modules from .openshift/cpan.txt
remote: --> Working on Exporter
remote: Fetching http://mirror.ops.rhcloud.com/mirror/perl/CPAN/authors/id/T/TO/TODDR/Exporter-5.70.tar.gz ... OK
remote: Configuring Exporter-5.70 ... OK
remote: Building Exporter-5.70 ... OK
remote: Successfully installed Exporter-5.70 (upgraded from 5.63)
remote: 1 distribution installed
remote: ! Finding Util on cpanmetadb failed.
remote: ! Finding Util () on mirror http://mirror.ops.rhcloud.com/mirror/perl/CPAN failed.
remote: ! Finding Util () on mirror http://search.cpan.org/CPAN failed.
remote: ! Couldn't find module or a distribution Util ()
remote: skipping R/RJ/RJBS/perl-5.20.0.tar.gz
remote: skipping R/RJ/RJBS/perl-5.20.0.tar.gz
remote: Preparing build for deployment
remote: Deployment id is ccb469ba
remote: Activating deployment
remote: Starting Perl cartridge
remote: Application directory "/" selected as DocumentRoot
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
To ssh://54900fb6769ee19cdb000001.rhcloud.com/~/git/perl.git/
   f840fe4..d284837  master -> master

Actual results:
6. Skip the failed CPAN modules to allow build to finish

Expected results:
6. Skip the failed CPAN modules to allow build to finish

Additional info:


Note You need to log in before you can comment on or make changes to this bug.