Skip to content

Instantly share code, notes, and snippets.

@jkeroes
Last active November 19, 2019 17:26
Show Gist options
  • Save jkeroes/5759286 to your computer and use it in GitHub Desktop.
Save jkeroes/5759286 to your computer and use it in GitHub Desktop.
Build Perl with perlbrew, libs, and cpanm

Install Perlbrew with the system perl

curl -L http://install.perlbrew.pl | bash

Initialize Perlbrew

mkdir /opt/perlbrew
export PERLBREW_ROOT=/opt/perlbrew
export PERLBREW_HOME=/opt/perlbrew
perlbrew init # and follow the directions

Configure perlbrew to use the Integra CPAN mirror

perlbrew mirror
m
http://cpan.integra.engr
Integra

Build Perl

9 threads seems good on my quad proc. Skip the tests.

perlbrew install -j 9 --notest 5.18.0

Set up module libs and cpanminus

Now you have a shiny new Perl. For modules, let's create environments for dev and for each application. The only shared modules are the core modules.

perlbrew use 5.18.0 # temporarily use this version
perlbrew lib create dev
perlbrew switch 5.18.0@dev # permanently switch to this version and lib.
perlbrew install-cpanm # installed to /opt/perlbrew/bin so all perlbrews can install modules

Modules will now be installed into /opt/perlbrew/libs/perl-5.18.0@dev/lib. Develop all you want here. Install any module you need. This is a playpen for development.

Option 1: Create an custom lib for your app with perlbrew

perlbrew lib create appname-prd
perlbrew list
perlbrew use 5.18.0@appname-prd

Install modules however you please. e.g.

alias cpanm='cpanm --mirror=http://cpan.integra.engr'
HARNESS_OPTIONS=j4 cpanm -S --installdeps .../path/to/project
HARNESS_OPTIONS=j4 cpanm -S Module1 Module2 ...
HARNESS_OPTIONS=j4 cpanm -S < list-of-modules.txt

If tests fail, try without the HARNESS_OPTIONS=j4.

Also, cpanm can install specific versions:

cpanm Plack~1.0000                 # 1.0000 or later
cpanm Plack~">= 1.0000, < 2.0000"  # latest of 1.xxxx
cpanm [email protected]                 # specific version. same as Plack~"== 0.9990"

Option 2: Ship a custom lib for your app with carton

https://metacpan.org/module/MIYAGAWA/carton-v0.9.15/lib/Carton/Doc/FAQ.pod#Im-already-using-perlbrew-and-local::lib.-Can-I-use-carton-with-this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment