Installed Module not contained in the Perl's #INC path - excel

I have an issue on including the Excel-Writer-XLSX module in the #INC path. I did some research before posting this question and tried several solutions, but they all failed.
So I did
$sudo perl -MCPAN -e 'install Excel::Writer::XLSX'
But after I run the code, I got this message
--can't locate Excel/Writer/XLSX.pm in #INC(you may need to install the Excel::Writer::XLSX module) (#INC contains: /Library/Perl/5.18/darwin-thread-multi-2level/...)
This is not a duplicate question, because the Excel::Writer::XLSX module has been successfully installed in my computer and I don't need to install it again. The thing is when I checked my library folder, the perl5 folder is not there, as it was suggested by the #INC path. Instead, Perl5 folder is in my user folder...and actually the module can be found in the lib folder inside the perl5 folder
I'm not quite sure what is happening...Why the #INC path shows the perl/5.18 is inside the library folder? If you know how to solve this issue, please advice. Thank you so much!

Make sure the #INC contains the path where your modules are getting installed. You can specify that by
export PERL5LIB=/home/foobar/code (For Linux) (Add this to ~/.bashrc to make it always available when you log-in.)
set PERL5LIB = c:\path\to\dir (For Windows)
Also see:
How do I 'use' a Perl module in a directory not in #INC?
How to change #INC to find Perl modules in non-standard locations

At the very top of your perl code right after #!/usr/bin/perl
BEGIN
{
push(#INC, '/home/penny/perlModules');
}
use my::module;
use File::Path;
...
This will allow your code to use any module you've installed in perlModules dir.
Downside is you have to modify code. Or you can use PERL5LIB env path as answered above.

Related

How to Call Custom Perl Module in a Script

I am installing mireap software on my Linux VM (https://sourceforge.net/projects/mireap/). After installation, I am unable to run the software as I am always getting the error that FFW1.pm module needs to be installed; however, the module is present in lib directory. The script failed to call the module from the library. I will really appreciate if you help me in this regard. The steps which I performed are there in the image.
It's not clear what you mean by "lib directory".
If you mean the the module is in a directory named lib, and that this directory is a subdirectory of the one in which the script is located, then this should be added to the script:
use FindBin qw( $RealBin );
use lib "$RealBin/lib";

Shopify's 'slate' package not running after installation

I just installed Shopify's 'Slate' package using npm.
Terminal shows that the package was added to '/.npm-packages/lib'.
However, when I attempt to build a new shopify theme using the command 'slate theme newthemename', the command isn't found...
...even though slate clearly was installed.
Curious to figure out what I'm doing wrong, so any help/advice is much appreciated!
Please execute the below command from your terminal.
npm link #shopify/slate
Basically this command creates a symlink to your package folder, it will check for the global (npm) modules first, and will check for the local modules if there is no match.
Hope this helps!
Your installation of slate is successful. However, the slate program (slate/lib/index.js) is not added to environment variable PATH, that's why error command not found is reported.
To fix this issue, a simple method is add slate/lib/index.js to PATH manually. For example, create a symbolic link in /usr/local/bin/ and make it point to slate/lib/index.js:
sudo ln -s /<absolute_path>/#shopify/slate/lib/index.js /usr/local/bin/slate
Please note the first parameter of ln -s must be absolute path. If relative path is used, Mac OS X (I'm on 10.12.6) won't help to translate it.

How to find the location of a Perl module on a Linux server?

We moved everything on our old server to a new server. One of the websites on our new server uses a Perl back-end. When I go to this Perl site in my browser it throws a 500 internal server error. When I run the Perl script from the command line like this:
perl -wc login.pl
I get this error:
Can't locate LoadINC.pm
and at the top of login.pl there is this:
#!/usr/bin/perl
BEGIN { use LoadINC; }
...
So it looks like that LoadINC Perl module is missing from our new server.
The old server is still running and doesn't have this issue. So my thought is to locate the LoadINC module on the old server and then put it in the same place on the new server. Or is there a better approach? Is the module hidden in some binary file? Are the places to look for Perl modules not the same on both servers?
One other thing to note, the Perl version on the old server is 5.8.8 and the version on the new server is 5.16.3.
How to find the location of a Perl module on a Linux server?
perl -mFoo::Bar -le'print $INC{"Foo/Bar.pm"}'
or
perldoc -lm Foo::Bar
In this case,
perl -mLoadINC -le'print $INC{"LoadINC.pm"}'
or
perldoc -lm LoadINC
So my thought is to locate the LoadINC module on the old server and then put it in the same place on the new server. Or is there a better approach?
How are we suppose to know how to install your module?
Most modules are installed using one of
perl Makefile.PL
make test
make install
or
perl Build.PL
./Build test
./Build install
Simply copying the file might work, but there are a number of reasons why it might not. On the plus side, you'll immediately know if it worked or not in most cases.
Are the places to look for Perl modules not the same on both servers?
The list of directories searched will definitely be different (given the difference in versions), though both builds may have directories in common.
Architecture-independent modules should be installed in the directory named by the output of the following command:
perl -V:installprivlib
use LoadINC will look for a file called LoadINC.pm. Perl searches the directories listed in #INC for modules. You can see them with
perl -wle 'print for #INC'
#INC is composed from a compiled-in list of directories, the contents of the environment variable PERL5LIB, any -I options on the command line, and whatever changes the running code may have made.
You can ask perldoc for the location of a file matching a module name:
perldoc -lm LoadINC
If you can load the module, you can also ask perl itself:
perl -wle 'use LoadINC (); print $INC{"LoadINC.pm"}'
(%INC is a hash that maps the base name of a loaded module to its path.)
One way to do it:
$ perldoc -lm open
/usr/lib/perl5/5.24.1/open.pm
Or the sledgehammer method:
$ locate -r open.pm$
/usr/lib/perl5/5.24.1/open.pm
But TMTOWTDI.

Switch to different version of Perl - modules version

I am trying to use a new version of perl - 5.18.1 and I get an error for one of the modules I am trying to use:
/usr/local/perl-5.18.1/bin/perl: symbol lookup error:
/home/riskprod/bin/lib/perl5/x86_64-linux-thread-multi/auto/Cwd/Cwd.so:
undefined symbol: Perl_Tstack_sp_ptr
I have cpan and use it for my modules. From my research it looks like the reason for the error is that it was built using different version of perl.
How can I change the version of the build? What would be the proper solution to this problem?
Some details
Here is what I have in bash_profile:
export PERL_LOCAL_LIB_ROOT="/home/riskprod/perl5:$PERL_LOCAL_LIB_ROOT";
export PERL_MB_OPT="--install_base "/home/riskprod/perl5"";
export PERL_MM_OPT="INSTALL_BASE=/home/riskprod/perl5";
export PERL5LIB="/home/riskprod/perl5/lib/perl5:$PERL5LIB";
export PATH="/home/riskprod/perl5/bin:$PATH";
Here is how I ran the cpan:
/usr/local/perl-5.18.1/bin/perl -MCPAN -e shell
I did this to reinstall:
force install Cwd
The module you are trying to use was compiled against a different build of Perl. It's not clear what you did for that to happen. Maybe you set PERL5LIB to point to an directory into which modules were installed using INSTALL_BASE? (Damn you, INSTALL_BASE!) You just need to reinstall the module, but it would also help to stop looking in whatever directory contains the that module.

module: command not found

I'm attempting to load several modules for building a library on Linux but am told that the command 'module' doesn't exist. I've Googled around and discovered that the solution was to source a directory called "module" which I am unable to locate despite extensive searching.
I'm not quite sure what I should and any help would be appreciated (it might help to know that the makefile I'm working with uses csh while my default shell is bash). Thanks!
I tried to reproduce it and it turns out that for me sourcing
source /etc/profile.d/modules.sh
in th .sh script helps for bash and similar. For csh and tcsh, you have to add
source /etc/profile.d/modules.csh
to the script. Note, that this line must come first and then the
module load foo
line.
I got here as I was searching for ways to install multiple php versions in CentOS7 and https://blog.remirepo.net/post/2019/05/22/PHP-7.4-as-Software-Collection was one of the articles I tried to follow and encountered the same "module: command not found" issue.
Sourcing /etc/profile via command:
. /etc/profile
seems to make the "module load" work.
Credits to fadishei in https://forums.fedoraforum.org/showthread.php?262708-module-command-not-found
To make the version of php (e.g. php7.4) persist, append the following to file /etc/profile.d/custom.sh
source /etc/profile.d/modules.sh
module load php74
Reboot and run the php --version to cross-check that php 7.4 is the current version installed.
I think that you have to put this in your script to define the module command:
module () {
eval `/usr/bin/modulecmd bash $*`
}
This was working for me
#!/bin/bash -i // it will make this interactive

Resources