07 May 2022 01:36:42 UTC
- Distribution: Carton
- Module version: v1.0.35
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (96)
- KwaliteeBus factor: 1
- % Coverage
- License: perl_5
- Perl: v5.8.5
- Download (83.87KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:60 non-PAUSE users
- PERL VERSIONS
- SEE ALSO
Carton - Perl module dependency manager (aka Bundler for Perl)
# On your development environment > cat cpanfile requires 'Plack', '0.9980'; requires 'Starman', '0.2000'; > carton install > git add cpanfile cpanfile.snapshot > git commit -m "add Plack and Starman" # Other developer's machine, or on a deployment box > carton install > carton exec starman -p 8080 myapp.psgi # carton exec is optional > perl -Ilocal/lib/perl5 local/bin/starman -p 8080 myapp.psgi > PERL5LIB=/path/to/local/lib/perl5 /path/to/local/bin/starman -p 8080 myapp.psgi
Carton only works with perl installation with the complete set of core modules. If you use perl installed by a vendor package with modules stripped from core, Carton is not expected to work correctly.
Also, Carton requires you to run your command/application with
carton execcommand or to include the local/lib/perl5 directory in your Perl library search path (using
-I, or lib).
carton is a command line tool to track the Perl module dependencies for your Perl application. Dependencies are declared using cpanfile format, and the managed dependencies are tracked in a cpanfile.snapshot file, which is meant to be version controlled, and the snapshot file allows other developers of your application will have the exact same versions of the modules.
cpanfilesyntax, see cpanfile documentation.
carton will use the local directory to install modules into. You're recommended to exclude these directories from the version control system.
> echo local/ >> .gitignore > git add cpanfile cpanfile.snapshot > git commit -m "Start using carton"
You can manage the dependencies of your application via
# cpanfile requires 'Plack', '0.9980'; requires 'Starman', '0.2000';
And then you can install these dependencies via:
> carton install
The modules are installed into your local directory, and the dependencies tree and version information are analyzed and saved into cpanfile.snapshot in your directory.
Make sure you add cpanfile and cpanfile.snapshot to your version controlled repository and commit changes as you update dependencies. This will ensure that other developers on your app, as well as your deployment environment, use exactly the same versions of the modules you just installed.
> git add cpanfile cpanfile.snapshot > git commit -m "Added Plack and Starman"
You can pin a module resolution to a specific distribution using a combination of
# specific distribution on PAUSE requires 'Plack', '== 0.9980', dist => 'MIYAGAWA/Plack-0.9980.tar.gz'; # local mirror (darkpan) requires 'Plack', '== 0.9981', dist => 'MYCOMPANY/Plack-0.9981-p1.tar.gz', mirror => 'https://pause.local/'; # URL requires 'Plack', '== 1.1000', url => 'https://pause.local/authors/id/M/MY/MYCOMPANY/Plack-1.1000.tar.gz';
Once you've done installing all the dependencies, you can push your application directory to a remote machine (excluding local and .carton) and run the following command:
> carton install --deployment
This will look at the cpanfile.snapshot and install the exact same versions of the dependencies into local, and now your application is ready to run.
--deploymentflag makes sure that carton will only install modules and versions available in your snapshot, and won't fallback to query for CPAN Meta DB for missing modules.
carton can bundle all the tarballs for your dependencies into a directory so that you can even install dependencies that are not available on CPAN, such as internal distribution aka DarkPAN.
> carton bundle
will bundle these tarballs into vendor/cache directory, and
> carton install --cached
will install modules using this local cache. Combined with
--deploymentoption, you can avoid querying for a database like CPAN Meta DB or downloading files from CPAN mirrors upon deployment time.
> cpanm -L local --from "$PWD/vendor/cache" --installdeps --notest --quiet .
When you take a snapshot in one perl version and deploy on another (different) version, you might have troubles with core modules.
The simplest solution, which might not work for everybody, is to use the same version of perl in the development and deployment.
To enforce that, you're recommended to use plenv and
.perl-versionto lock perl versions in development.
You can also specify the minimum perl required in
requires 'perl', '5.16.3';
and carton (and cpanm) will give you errors when deployed on hosts with perl lower than the specified version.
Code repository, Wiki and Issue Tracker
Tatsuhiko Miyagawa 2011-
This software is licensed under the same terms as Perl itself.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|