What are common pitfalls or gotchas with carton and cpanfile?

When using Carton with a cpanfile in Perl, developers may encounter several common pitfalls or gotchas. Understanding these can save time and prevent frustration.

Common Pitfalls

  1. Not Including All Dependencies: Forgetting to specify a dependency in the cpanfile can lead to runtime errors. Always review your dependencies to ensure they are included.
  2. Using Global Modules: Relying on globally installed modules rather than using Carton can cause conflicts. Stick to the local environment managed by Carton.
  3. Caching Issues: Sometimes, Carton may cache old versions of modules. To resolve this, clear the cache and reinstall your dependencies.
  4. Different Environments: Ensure that your development and production environments have the same Perl version and module versions to avoid compatibility issues.
  5. Updating the cpanfile: When you add a new module, forget to update both the cpanfile and the lock file can lead to discrepancies in the dependency versions used.

Example cpanfile

use ExtUtils::MakeMaker; WriteMakefile( NAME => 'MyApp', VERSION_FROM => 'lib/MyApp.pm', PREREQ_PM => { 'Moo' => '2.003006', 'DBI' => '1.643', }, );

Perl Carton cpanfile dependencies package management