# 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
Also, Carton requires you to run your command/application with "carton exec" command, which means it's difficult or impossible to run in an embedded perl use case such as mod_perl.
For "cpanfile" syntax, see cpanfile documentation.
> echo local/ >> .gitignore > git add cpanfile cpanfile.snapshot > git commit -m "Start using carton"
# 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"
> 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.
The "--deployment" flag 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 bundle
will bundle these tarballs into vendor/cache directory, and
> carton install --cached
will install modules using this local cache. Combined with "--deployment" option, you can avoid querying for a database like CPAN Meta DB or downloading files from CPAN mirrors upon deployment time.
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-version" to lock perl versions in development.
You can also specify the minimum perl required in "cpanfile":
requires 'perl', '5.16.3';
and carton (and cpanm) will give you errors when deployed on hosts with perl lower than the specified version.