How to install Perl modules from CPAN to be used in 3rd party plugin

tarasm

Registered
Sep 21, 2010
4
0
51
Hello,

We're working on a plugin that requires a module from CPAN.
We installed it via /scripts/perlinstaller. The module shows up in WHM - Install a Perl Module, but when we try to INC it, we get

Code:
Can't locate Git/Repository.pm in @INC (@INC contains: 
/usr/local/cpanel 
/usr/local/cpanel/perl 
/usr/local/cpanel/Cpanel/CPAN/overload/__Digest 
/usr/local/cpanel/Cpanel/CPAN/overload/__Time 
/usr/local/cpanel/build-tools/stubs 
/usr/local/cpanel/perl/C220 
/usr/local/cpanel/perl/5.6.2/i686-linux 
/usr/local/cpanel/perl/5.6.2/i686-linux 
/usr/local/cpanel/perl/5.6.2 
/usr/local/cpanel/perl/site_perl/5.6.2/i686-linux 
/usr/local/cpanel/perl/site_perl/5.6.2/i686-linux 
/usr/local/cpanel/perl/site_perl/5.6.2 
/usr/local/cpanel/perl/site_perl/5.6.2/i686-linux 
/usr/local/cpanel/perl/site_perl/5.6.2 
/usr/local/cpanel/perl/site_perl 
. 
/usr/local/cpanel/perl/5.6.2/i686-linux 
/usr/local/cpanel/perl/5.6.2 
/usr/local/cpanel/perl/site_perl/5.6.2/i686-linux 
/usr/local/cpanel/perl/site_perl/5.6.2 
/usr/local/cpanel/perl/site_perl .it) 

at /usr/local/cpanel/Cpanel/RepositoryManager.pm line 8.
	Cpanel::RepositoryManager::BEGIN() called at Git/Repository.pm line 8
	eval {...} called at Git/Repository.pm line 8
	require Cpanel/RepositoryManager.pm called at (eval 78) line 1
	eval ' require Cpanel::RepositoryManager; Cpanel::RepositoryManager::RepositoryManager_init(); 
;' called at /usr/local/cpanel/Cpanel/LoadModule.pm line 19
	Cpanel::LoadModule::_modloader('RepositoryManager') called at /usr/local/cpanel/Cpanel/LoadModule.pm line 23
	Cpanel::LoadModule::loadmodule('RepositoryManager') called at /usr/local/cpanel/Cpanel/Api2/Exec.pm line 33
	Cpanel::Api2::Exec::api2_preexec('RepositoryManager', 'log') called at cpanel line 558
	main::real_cpexectag('<?cp RepositoryManager::log(%,key) ?>') called at cpanel line 3827
	main::dotag_finished_headers(0) called at cpanel line 3652
	main::cpanel_parseblock('<!--^JHSTD Repository Manager^JCopyright (C) 2010 HSTD.org^J^JThis p...') called at cpanel line 3560
	main::cpanel_parse('GLOB(0x96e6554)') called at cpanel line 5048
	main::run_standard_mode() called at cpanel line 421
What's the proper way of installing a Perl module that a plugin uses?
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
Are you calling the plugin from cPanel? cPanel parsed CGI script use the internal cPanel Perl (/usr/local/cpanel/perl) rather than the Perl that /scripts/perlinstaller is using which is site_perl. Unfortunately, it's pretty complex to add your own Perl modules to this Perl but cPanel support can tell you how to do it. They are using Perl 5.6.1 or 5.6.2 I believe which can cause module compatibility issues as well.

If you want a workaround, use a module that exists in their perl (/usr/local/cpanel/perl) like IPC::Open3 to exec the perl script and the exec will be called by the system Perl rather than cPanel's Perl. This will allow you to use modules installed by /scripts/perlinstaller.
 

tarasm

Registered
Sep 21, 2010
4
0
51
I'm thinking about including the library that we need from CPAN in our distribution and moving it to /usr/local/cpanel/perl during installation. Would that work?
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
I'm thinking about including the library that we need from CPAN in our distribution and moving it to /usr/local/cpanel/perl during installation. Would that work?
Maybe. A lot of the libraries in /usr/local/cpanel/perl are statically compiled. Notice the perl.h and such. If it's compatible with 5.6.2 (or 5.6.1, I cannot remember which they use) it can work depending on its dependencies. However, I'm not sure how cPanel updates /usr/local/cpanel/perl/ so you may want to contact them to see if it'll be wiped out on cPanel updates.

On a side note: This type of issue definitely shows the need for a new plugin system. Somewhere that plugins can be packaged up to work with cPanel and not have to have their components tossed around all over the place. If anyone gets a chance, please put in a vote or a feature request for such a system, it would really improve the development community.
 

tarasm

Registered
Sep 21, 2010
4
0
51
On a side note: This type of issue definitely shows the need for a new plugin system. Somewhere that plugins can be packaged up to work with cPanel and not have to have their components tossed around all over the place. If anyone gets a chance, please put in a vote or a feature request for such a system, it would really improve the development community.
I'm going to request that one of the cPanel staff creates a Feature Request and references this thread, because I'm sure that they have been talking about this.

We're going to try the strategy that I described and report back on this thread.