# Perl upgrade and issue with (perl -v)



## Bob Walter (Apr 3, 2017)

I upgraded from perl5.22 to perl5.24 via ports. I changed the make.conf default to 5.24 and set the package origin to 5.24 as well. Portmaster seemed to build all the dependent ports correctly against 5.24.

The problem is that if I do `perl -v` I get 5.22 as the default. I tried uninstalling 5.22 and reinstalling 5.24. Then no perl was found when I did `perl -v`. I verified that perl 5.24 is installed. How do I fix this so that perl -v shows 5.24?


----------



## SirDice (Apr 4, 2017)

Bob Walter said:


> I changed the make.conf default to 5.24 and set the package origin to 5.24 as well.


The default is already set to 5.24, see /usr/ports/Mk/bsd.default-versions.mk:

```
PERL5_DEFAULT?=         5.24
```

Also read /usr/ports/UPDATING:

```
20161103:
  AFFECTS: users of lang/perl5*
  AUTHOR: mat@FreeBSD.org

  The default Perl version has been switched to Perl 5.24.  If you are using
  binary packages to upgrade your system, you do not have anything to do, pkg
  upgrade will do the right thing.  For the other people, assuming you are
  migrating from 5.20 to 5.24, do:

  First, add to /etc/make.conf:

  DEFAULT_VERSIONS+=  perl5=5.24

  Portupgrade users:
        portupgrade -o lang/perl5.24 -f lang/perl5.20

          You can now remove the DEFAULT_VERSIONS line added earlier
          from /etc/make.conf

          Then you will need to rebuild everything that uses libperl.so, you
          can do so with:

        portupgrade -f `pkg shlib -qR libperl.so.5.20`

  Portmaster users:
        portmaster -o lang/perl5.24 lang/perl5.20

          You can now remove the DEFAULT_VERSIONS line added earlier
          from /etc/make.conf

          Then you will need to rebuild everything that uses libperl.so, you
          can do so with:

        portmaster -f `pkg shlib -qR libperl.so.5.20`
```


----------



## Bob Walter (Apr 4, 2017)

> Portmaster users:
> portmaster -o lang/perl5.24 lang/perl5.20
> 
> You can now remove the DEFAULT_VERSIONS line added earlier
> ...



Is the version in the command above pointing to the OLD version (in your case 5.20) or the NEW version 5.24? I just wondered if the command is correct.


----------



## SirDice (Apr 5, 2017)

The above commands replace Perl 5.20 with Perl 5.24. So you'll need to adjust it slightly because you're replacing Perl 5.22 with Perl 5.24.


----------



## Bob Walter (Apr 5, 2017)

I did all the steps as suggested. Everything rebuilt. However, when I do _Perl -v_ 
The command returns "This is perl 5, version 22, subversion 3

Shouldn't it now say Perl 5, version 24?


----------



## SirDice (Apr 6, 2017)

What does `ls -li /usr/bin/perl* /usr/local/bin/perl*` output?


----------



## Bob Walter (Apr 6, 2017)

Here it is 

```
$ ls -li /usr/bin/perl* /usr/local/bin/perl*
236874 lrwxr-xr-x  1 root  wheel     19 Oct 13  2015 /usr/bin/perl -> /usr/local/bin/perl
426959 -rwxr-xr-x  3 root  wheel   7536 Apr  5 10:03 /usr/local/bin/perl
426959 -rwxr-xr-x  3 root  wheel   7536 Apr  5 10:03 /usr/local/bin/perl5
426959 -rwxr-xr-x  3 root  wheel   7536 Apr  5 10:03 /usr/local/bin/perl5.22.3
428069 -rwxr-xr-x  1 root  wheel   7568 Apr  4 09:19 /usr/local/bin/perl5.24.1
426996 -rwxr-xr-x  2 root  wheel  45405 Apr  5 10:00 /usr/local/bin/perlbug
428070 -rwxr-xr-x  2 root  wheel  45417 Apr  4 09:16 /usr/local/bin/perlbug5.24.1
426997 -rwxr-xr-x  1 root  wheel    274 Apr  5 10:00 /usr/local/bin/perldoc
428071 -rwxr-xr-x  1 root  wheel    286 Apr  4 09:16 /usr/local/bin/perldoc5.24.1
427012 -rwxr-xr-x  1 root  wheel  10829 Apr  5 10:00 /usr/local/bin/perlivp
428072 -rwxr-xr-x  1 root  wheel  10847 Apr  4 09:16 /usr/local/bin/perlivp5.24.1
426996 -rwxr-xr-x  2 root  wheel  45405 Apr  5 10:00 /usr/local/bin/perlthanks
428070 -rwxr-xr-x  2 root  wheel  45417 Apr  4 09:16 /usr/local/bin/perlthanks5.24.1
$
```


----------



## SirDice (Apr 6, 2017)

Looks like you managed to get both perl5.22 and perl5.24 installed. That's definitely going to cause problems as that's never meant to happen. As you can see by the first number (that's the file's inode(5)) /usr/local/bin/perl and /usr/local/bin/perl5 are the same file as /usr/local/bin/perl5.22.3. That's why `perl -v` reports 5.22.3. 

Double check you don't have both ports/packages installed: `pkg info -Eg perl5`. It should only show perl5-5.24.1. Remove the left-overs from 5.22 and fix the links:

```
rm /usr/local/bin/perl
rm /usr/local/bin/perl5
ln /usr/local/bin/perl5.24.1 /usr/local/bin/perl
ln /usr/local/bin/perl5.24.1 /usr/local/bin/perl5
```

That should fix things. But there may be other left-overs in /usr/local/lib/perl5/. Luckily those are mostly separated by their version numbers. It shouldn't interfere but check it anyway.

Edit: It definitely can't hurt because it looks like my system collected a bunch of old stuff over the past years too:

```
root@molly:~ # ll /usr/local/lib/perl5/
total 9
drwxr-xr-x   4 root  wheel    4 Nov  2  2013 5.14/
drwxr-xr-x   5 root  wheel    5 Dec 23  2014 5.16/
drwxr-xr-x   3 root  wheel    3 Jul  9  2015 5.18/
drwxr-xr-x   3 root  wheel    3 Nov  6 12:49 5.20/
drwxr-xr-x  54 root  wheel  126 Jan 22 17:03 5.24/
drwxr-xr-x   7 root  wheel    9 Mar 27 23:08 site_perl/
```
Everything works correctly though. I like Perl so I use it often enough


----------



## Bob Walter (Apr 7, 2017)

I made sure 5.22 was gone. I installed 5.24. Then perl -v showed no such command as perl

Just for fun, I checked and /usr/local/bin/perl and /usr/local/lib/perl5 were missing. So I did the ln /usr/local/bin/perl5.24 to /usr/local/bin/perl and the same to the /usr/local/lib/perl5.

Somehow the two files disappeared. I've never seen that happen before. 

I think all is fixed. Not sure how to check. perl -v does report 5.24 now. I did the port rebuild earlier with the commands you gave when first explaining. I assume they did the necessary.

Thanks!


----------



## Bob Walter (Apr 7, 2017)

A new, disturbing development. I tried to use webmin. it wouldn't start in its browser. So I uninstalled it and reinstalled it. When I finished, perl5.22 was now in place when I did a perl -v. pkg info -Eg showed perl5.22.3. I'm totally lost now.


----------



## Bob Walter (Apr 7, 2017)

I made a mess somehow. I started again from the beginning.  Now all seems to be well. Thanks for your help.


----------

