LinuxCommandLibrary

cpanp

Install and manage Perl modules

SYNOPSIS

cpanp [OPTIONS] [COMMAND] [MODULE_OR_ARGUMENTS ...]

Common COMMANDs:
  install Module::Name
  upgrade Module::Name
  search keyword
  shell
  autobuild
  info Module::Name
  lookup Module::Name
  rebuild

PARAMETERS

-i, --install
    Install specified Perl modules.

-u, --upgrade
    Upgrade specified Perl modules to their latest versions.

-s, --search
    Search the CPAN index for modules matching a keyword.

-e, --shell
    Enter an interactive cpanp shell for advanced operations.

-b, --autobuild
    Build and install modules without prompting.

-f, --force
    Force operations, e.g., reinstalling modules or proceeding despite warnings.

-n, --noconfirm
    Do not ask for confirmation; assume 'yes' to all prompts.

-v, --verbose
    Increase verbosity of output.

-D, --debug
    Enable debug output for detailed troubleshooting.

-F, --force-install-with-tests
    Force installation even if tests fail.

--show-config
    Display the current CPANPLUS configuration.

--test
    Only run tests for a module, do not install.

-h, --help
    Display a short help message and exit.

-V, --version
    Display version information and exit.

DESCRIPTION

cpanp is a command-line utility for installing, managing, and interacting with Perl modules from the Comprehensive Perl Archive Network (CPAN). It serves as an alternative, and often more user-friendly, interface to the traditional cpan shell. Built upon the CPANPLUS Perl module, cpanp aims to simplify the process of acquiring and deploying Perl software by automating common tasks such as fetching module distributions, resolving dependencies, running tests, and performing installations. It provides an intuitive command-line interface, offering commands for installing new modules, upgrading existing ones, searching the CPAN repository, and even entering an interactive shell for more complex operations. cpanp handles dependency chains automatically, prompting the user for decisions when necessary, but also allowing for non-interactive operations. Its design focuses on ease of use and robust management of the Perl module ecosystem.

CAVEATS

cpanp relies entirely on the underlying CPANPLUS Perl module, which must be installed and correctly configured. While designed for user-friendliness, its initial setup or advanced configuration (via CPANPLUS::Config::User.pm) can sometimes be complex for new users. Although robust, cpanp may occasionally be slower than the more minimalist cpan client for simple module installations due to its more comprehensive feature set and dependency management overhead. Furthermore, CPANPLUS and thus cpanp have seen less active development compared to the core cpan client in recent years, though it remains a viable and stable tool.

CONFIGURATION

cpanp's behavior is managed by the underlying CPANPLUS configuration. This configuration is typically stored in a Perl module file, most commonly located at ~/.cpanplus/lib/CPANPLUS/Config/User.pm. This file allows users to define default mirrors, build preferences, testing options, and other customizations. If this file doesn't exist, cpanp will guide the user through an initial setup process.

INTERACTIVE SHELL

Invoking cpanp shell (or cpanp -e) opens an interactive prompt similar to the traditional cpan shell. This mode allows users to execute multiple commands (e.g., 'install', 'test', 'info') without repeatedly typing 'cpanp', offering a persistent environment for module management and exploration.

MODULE INSTALLATION PROCESS

When you request to install a module, cpanp typically performs the following steps:
1. Download: Fetches the module distribution from a configured CPAN mirror.
2. Unpack: Extracts the distribution archive (usually a .tar.gz file).
3. Dependencies Check: Identifies and resolves any required prerequisite modules, potentially installing them first.
4. Build: Executes the `perl Makefile.PL` or `Build.PL` script, followed by `make` or `Build` (if applicable).
5. Test: Runs the module's test suite (`make test` or `Build test`).
6. Install: Places the module files in the appropriate Perl library directories (`make install` or `Build install`).

HISTORY

cpanp emerged as part of the CPANPLUS project, which began development in the early 2000s (around 2003-2004). Its primary motivation was to provide a more modern, robust, and programmatic alternative to the original cpan shell, which, while functional, was often perceived as less user-friendly and harder to integrate into automated scripts. CPANPLUS aimed to offer better dependency resolution, more configurable options, and a cleaner interface, with cpanp being its flagship command-line utility. It quickly gained popularity among Perl developers seeking a more streamlined and automated way to manage their module installations.

SEE ALSO

perl(1), cpan(1), perldoc(1), make(1), sudo(8)

Copied to clipboard