How to uninstall from `Carton` - perl

I have Carton environment and install modules into ./local/ from cpanfile. But now I do not require some modules and want to remove some.
I can remove ./local folder and install modules from scratch but this take a time. I have found this
carton uninstall Module
But it does not exists anymore.
Is there something like carton uninstall?

I workaround I just delete local folder and install modules from scratch:
rm -r local
carton
UPD
Note: This can take a while to install from scratch.
Thus to save time you can pass --notest option to cpanm via PERL_CPANM_OPT:
PERL_CPANM_OPT=--notest carton
Or if you you want to prevent querying for new versions:
carton install --deployment
This will install modules without testing them. This is safe in compare to previous command because you know that module was installed before (tests were PASS)

Related

Does local::lib support installing to the project directory?

With node, when I run npm install things get installed into ./node_modules. Is there any method to make all of my Perl modules install local to the project directory? Not to my home directory, or to my system?
Something like ./perl_modules?
You can do this with cpanm with --local-lib-contained=node_modules
cpanm --local-lib-contained=perl_modules install Mojo
Then you can run tell perl to use it by setting -I like this,
perl -I./perl_modules/lib/perl5/ -MMojo -E1

How to install Carton module into local project with perlbrew?

I use perlbrew to easy switch between perl.
I use Carton to install modules only for current project into /local directory.
But when I deploy application on new host.
I do:
perlbrew install -v -j 8 --notest --switch perl-5.30.3
perlbrew install-cpanm
cpanm Carton
But last step will install Carton into perlbrew libs
Is there a way to install Carton into my project local/lib/perl5 directory?
I want to keep base perlbrew clean
To install modules into your own directory we can use --local-lib option.
It is mentioned here and described at examples cpanm --help
cpanm --local-lib ./local
probably useful options for this task are:
-n,--notest Do not run unit tests
--self-contained Install all non-core modules, even if they're already installed
If you do deploy often probably you do not need to retest each time. This is meaningless.
Second option is useful when you want modules to be installed into you local directory despite on they are already installed into system/brew perl

perl carton cpanfile, optional install into main perl environment

I have a carton cpanfile. on servers on which I have sudo, I would be happy to install the latest versions of my modules globally instead.
do I write a script that removes the 'requires' and uses cpan -i (although I am concerned that I may have too many to fit the command line limit), or is this functionality already somewhere else?
If there is a cpanfile you can just run
$ cpanm --installdeps .
as root (with sudo) in the directory with the cpanfile and cpanm will read it and install your dependencies to whatever Perl is configured for this cpanm.
You can ignore carton for that completely.

CPAN Requirements File

With pip you are able to create a requirements file to specify which libraries to install. Is there an equivalent for perl modules using CPAN?
I came across ExtUtils::MakeMaker, but this seems like the make file is for each module specifically.
I guess to try and give a better idea of what I am asking is if there is a way to do something like
cpan install -r requirements.txt
and then specify which modules to install in that requirements file.
Thanks in advance!
When you install modules from CPAN, each module specifies its dependencies in the Makefile.PL (or Build.PL) and the CPAN shell will resolve those dependencies recursively when installing.
If you want to specify dependencies for an application (rather than a CPAN module), you can create a file called cpanfile in this format:
requires 'JSON';
requires 'Template';
requires 'DateTime';
requires 'DBIx::Class';
Then you can install those dependencies with one command:
cpanm --installdeps .
The cpanm command comes from the App::cpanminus distribution and is an alternative tool for installing modules from CPAN.
See the cpanfile docs for more information.
I think Carton is what you're looking for.
To start using Carton, install it. Then create a cpanfile with your dependencies:
require 'Test::Most';
require 'Math::BaseConvert';
With this file in place, run
carton install
This will install those modules, if necessary, and write a file called cpanfile.snapshot with dependency information.
Also see: Brief Notes on Managing Perl Dependencies with Carton
PS: Check out Stratopan.

How can I install Perl module without using CPAN.pm?

Is it possible?
If you download the source code, and read the README file. This will probably tell you you should do
perl Makefile.PL
make
make test
make install
or
perl Build.PL
./Build
./Build test
./Build install
If you download the source code, it will generally have a Makefile.PL. You run "perl Makefile.PL; make; make test; make install" and it will build and install for you.
Obviously if you're not using CPAN.pm, you're going to have to deal with dependencies yourself.
Also, if the reason you can't use CPAN.pm is that you don't have permission to install into /usr/lib/perl, you can force CPAN.pm to install locally, but I forget how.
If you are on a Linux box, a very large portion of the packages can usually be obtained using the built in package manager. For instance, on an Ubuntu system, if you want to install the PostgreSQL Perl module you'd simple do:
sudo apt-get install libpg-perl
You can see a list of the modules for Ubuntu here: http://packages.ubuntu.com/hardy/perl/
I find I can often guess at the names myself. Not sure if this helps at all, but for myself I often find this easier to use than CPAN as it does a lot better at resolving dependencies.
See here: How to install perl modules using CPAN without root
I have just set this up on a server without root access and CPAN does everything automatically.
But if you really wanna install a module without CPAN and you don't have root (assuming this since you don't wanna use CPAN), you can do it as follows
perl Makefile.PL PREFIX=$HOME
make
make install
You're gonna have to hunt down dependencies yourself so it's better to use CPAN.
If the problem is no root access, I would recommend looking at local::lib and also this webpage for CPAN.pm and non-root installation.
But to answer the question as asked, CPAN or CPANPLUS are helpful, but they aren't required. You can always do it the old-fashioned way as Leon says - though usually, it's easier not to.
If you are using Red Hat (Fedora, CentOS), you should use RPM for Perl dependencies wherever possible. Perl packages are almost always named perl-Module-Name, e.g. perl-DBI, perl-Spreadsheet-WriteExcel, etc.
On Ubuntu the naming scheme is libmodule-name-perl.
If the .pm file is pure Perl and doesn't need to be compiled you can just put it in your application's lib folder and use it as normal.
We can install all perl modules both from and even with your terminal in ubuntu. If you are using a ubuntu server then execute the following command ,
'sudo apt-get install "perl_module"'
The modules which you want just give the name in "perl_module" means If you want to install Apache2::Cookie it will be in "libapreq2" so you have to give like,
"sudo apt-get install libapreq2"
I, as others have would highly suggest using CPAN.pm. It is a breeze to use and can resolve any dependencies associated with the module you need automatically.
On the other hand, I would suggest that you read the perlmodinstall document over at perldoc as it gives details on other os' as well.
Regards,
Jeff
If you're asking this because you're having problems with CPAN... you're probably running out of RAM that's why you can't use CPAN.
Maybe you don't have a swap file. Try this:
$ sudo su
# dd if=/dev/zero of=/swap bs=1M count=1k # create a 1GB file
# mkswap /swap
# swapon /swap
Otherwise... stop some services.
$ sudo service mysql stop
$ sudo service nginx stop
...And try again
$ cpan install CPAN
$ cpan install MIME::Lite::TT::HTML