3

OK, got myself a clean virtual machine running Debian 9 (Stretch). I installed Dancer2 from the Debian package system. It's running version 0.204002. The Dancer2 software is telling me that the latest version is 0.205002.

I want to finally, once and for all, learn the proper way to upgrade Perl modules on a Debian machine to the latest and greatest versions without ruining the Debian dpkg dependencies. How do I achieve this?

EDIT Yes, this is a development machine I'm just playing with. But what if I wanted to run the latest version of Dancer 2 on a production machine? How would I do it?

StevieD
  • 6,925
  • 2
  • 25
  • 45
  • `cpan Dancer2`? The downside of CPAN is that you cannot uninstall (easily) and it won't auto-update. – PerlDuck Dec 05 '17 at 10:37
  • @PerlDuck `cpanm` [allows you to uninstall](https://metacpan.org/pod/distribution/App-cpanminus/bin/cpanm#-uninstall,-U), if there is a proper packlist. – simbabque Dec 05 '17 at 10:57
  • I've closed your question as a duplicate. The first and second answer of that question are spot-on. The second is more modern. Please consider _not using the system Perl_ in production. On your fresh VM this is fine, if it's only for development. But as soon as that box does anything else, you might mess up something, because the system Perl is meant for the system. Some core Linux utilities use it, and stuff like Dancer has a huge dependency chain, so a lot of things might get updated when you install it, and that could break things, especially if your dist had custom patches on modules. – simbabque Dec 05 '17 at 10:59
  • Right, this is a development machine. But I want to learn how to do it properly as if it were a production machine. – StevieD Dec 05 '17 at 11:02
  • If i wanted to run the latest version of Dancer 2 on a production machine, how would I do it properly? – StevieD Dec 05 '17 at 11:04
  • @simbabque I don't like the 2nd answer in the post you refer to because it uses `sudo` to run CPAN. I think your list of answers is ordered differently. – PerlDuck Dec 05 '17 at 11:04
  • 1
    @PerlDuck I meant the one with 50ish votes. It does use `sudo` to install, yes. But it also talks about cpanm's bootstrapping technique, which is fine. There should be something about local::lib. I think there is another such question that we often use a dup target, but I can't find it right now. If you find a better target, I'll reopen and change it. – simbabque Dec 05 '17 at 11:07
  • The answers to that question you marked mine as a duplicate of don't answer my question at all. – StevieD Dec 05 '17 at 11:11
  • I have reopened. The fact that you are running Debian doesn't really matter. There is some stuff in the Dancer documentation. I will write something down here later. – simbabque Dec 05 '17 at 14:43

1 Answers1

1

I can't tell that the following is the answer for the I want to finally, once and for all, learn the proper way... , but this is how me doing it in all my deployments.

  1. Install anyenv sudo git clone https://github.com/riywo/anyenv /opt/anyenv - you could deploy it into your $HOME as git clone https://github.com/riywo/anyenv ~/.anyenv but myself prefering some commonly accessible place. This step isn't mandatory, but for me help managing other local installations as node and such.
  2. change ownership: sudo chown -R jm666 /opt/anyenv - you will manage the content
  3. add into the .profile:
export ANYENV_ROOT=/opt/anyenv
export PATH="$ANYENV_ROOT/bin:$PATH"
eval "$(anyenv init -)"

Relog, or run exec $SHELL -l. Now you have installed an helper for all commonly needed environments.

Now install the perl env. helper, called plenv.

anyenv install plenv

Or follow the guide in the repo if you don't want the previous anyenv step.

And finally install fresh perl using plenv:

plenv install -l #will display all available perl versions
plenv install 5.26.1 -j 8 # number of proc cores or less. :)

This will take some time - on my notebook 4m23,186s - just tested :).

plenv global 5.26.1 # now all `perl script.pl` will use the freshly installed perl
plenv install-cpanm
plenv rehash #needed if you install some commands which should be accesible from `bash`

And you're ready to install any perl modules using cpanm - without compromising the system-wide installed perl. Everything will be installed into the plenv's directory tree. Even, you never need be root.

This way I could manage to have the same development and deployment environment. Maybe here is a better way - but for me the above works.

In short, read:

clt60
  • 62,119
  • 17
  • 107
  • 194