2022 twenty-four merry days of Perl Feed

Relocatable Perl

relocatable-perl - 2022-12-16

On May 2022, perl v5.36 was released. Now I always write perl with

  use v5.36;

and I'm very excited to use new features.

Unfortunately I don't think too many people use perl v5.36 yet. This is because system perls are often out-of-date, so people don't have many chances to use the latest perl.

It is true that you, an experienced Perl hacker, could build perl v5.36 by yourself. But people who are not very familiar with Perl rarely build perl from source.

Some programming languages, including nodejs and golang, provide their pre-built binaries. This helps people get started and use the latest version of the languages.

So what if perl also provides its pre-built binaries?

Because perl itself does not depend on external libraries (except for glibc on linux, etc.), it seems that we can prepare portable perl binaries for each OS/arch. Additionally, since v5.10, perl can be built with relocatable INC so that we can relocate the perl tree wherever we want.

Well, I prepared pre-built relocatable-perls for

  • linux amd64

  • linux arm64

  • macOS amd64

  • macOS arm64 (for M1/M2 chips)

Are these useful? Let's give it a try!

Install relocatable-perls

There are 3 ways to install relocatable-perls.


You can manually download tarballs for your OS/arch from release page. For example, if you use macOS with the M1 chip, then

  $ curl -fsSL -o perl-darwin-arm64.tar.xz https://github.com/skaji/relocatable-perl/releases/latest/download/perl-darwin-arm64.tar.xz
  $ tar xf perl-darwin-arm64.tar.xz
  $ mv perl-darwin-arm64 ~/wherever-you-want
  $ ~/wherever-you-want/bin/perl -v
  This is perl 5, version 36, subversion 0 (v5.36.0) built for darwin-2level

One liner

A helper script perl-install helps you to install relocatable-perls:

  $ curl -fsSL https://raw.githubusercontent.com/skaji/relocatable-perl/main/perl-install | bash -s ~/perl

This installs the latest relocatable-perl into ~/perl.


If you use plenv, then plenv-download may be useful:

  $ git clone https://github.com/skaji/plenv-download $(plenv root)/plugins/plenv-download
  $ plenv download latest
  Downloading https://github.com/skaji/relocatable-perl/releases/download/
  Unpacking /Users/skaji/env/plenv/cache/relocatable-
  Successfully installed

How to use relocatable-perls

You can use relocatable-perls just like your usual perls. I have been using relocatable-perls for 8 years and don't have any particular problems.

Relocatable-perls come with cpanm so that you are ready to use CPAN modules!

  $ cpanm -nq Plack
  $ plackup -p 8080 -e 'sub {[200,[],["hello world!"]]}'
  HTTP::Server::PSGI: Accepting connections at http://0:8080/


I think pre-built binaries helps people get started with perl and use the latest version of perl. I prepared relocatable-perls so that you can give it a try now!

Gravatar Image This article contributed by: Shoichi Kaji <skaji@cpan.org>