3

I tried to upgrade Perl and put my computer into a complete mess I am currently running RHEL6.5, 64bits, and this is the thing:

  • I had perl-5.10.1 installed, and working nice. this came installed, and I could see it from yum
  • I wanted to install Padre, an Perl IDE, but that required at least v5.11 [I was so close! :( ]
  • There were no newer version for Perl in the repos that I have access to (and I have a limitation that I can't add new repos)
  • I got approval from my boss to download perl-5.20 .0 from www.perl.org and tried to install it

... and the mess begins!

  • First I installed the new perl with my own id, and that pushed perl to somewhere under my home dir
  • I tested with 'perl -v' and could see that my env was pointing to the newer install, however, yum never recognized it (not really a problem)
  • When I tried to install Padre, seems somehow it had the hardcoded the original perl (from /usr/bin) and still claiming for something as newer as 5.11.
  • Trying to fix it, I did installed the new perl again, now using root, to make it push perl under /usr tree ... it installed, but pushed perl to /usr/local/bin, instead of /usr/bin
  • So again, I had one more perl install but Padre still looking for the one on /usr/bin

I give up about Padre, and deleted the files related to it, as well as the perl installed on my home dir, however a couple of perl scripts that I had already coded now are throwing errors like:

perl -cw "xmltest.pl" (in directory: /home/myid/scripts/xmltest.pl)
perl: symbol lookup error: /usr/lib64/perl5/auto/Data/Dumper/Dumper.so: undefined symbol: Perl_Istack_sp_ptr
Compilation failed.

... and Data::Dumper in not the only one ... every time I disable one of the modules, another one hangs in the same, or similar way

From what I read about this, seems that this issue is related to modules that were originally installed for one perl version, and are being called by another, however, I already forced the modules that I use to be reinstalled directly from CPAN, and they still failing

Question: How can I, safely, get free from this current perl installs, and perform a new clean install be able to use it w/o these versions conflicts?

My major concern are about the numerous apps that I have that depends on Perl, and I my not broke then on a uninstall

Any help will be much appreciate.

Renato
  • 161
  • 1
  • 13
  • 2
    (5.odd are dev versions. You shouldn't install those.) – ikegami Sep 13 '14 at 00:33
  • `perl -V` (uppercase "V") tells you where your `perl` searches for modules, so you know what to start deleting... As for safely? Well, for all I know, your package manager might need Perl, so who knows! – ikegami Sep 13 '14 at 00:35
  • tkx @ikegami ... move to another version, such as 5.19 or anything like that would not be a constraint ... but first, I need to get free from this mess! :-( – Renato Sep 13 '14 at 00:37
  • When you say you're deleting, you mean you're moving, right? – ikegami Sep 13 '14 at 00:39
  • 2
    Also, if you move to another version, make sure not to overwrite the system Perl this time. `perlbrew` can help you install one in your home dir. – ikegami Sep 13 '14 at 00:40
  • For Padre files and those pushed to my /home tree, I really deleted ... for others, under /usr tree, I put them in a tar file, but did not deleted anything yet, as I was concerned about others apps – Renato Sep 13 '14 at 00:46

3 Answers3

8

You should:

  1. cleanup

    • clean (comment out) your ~/.profile from any unwanted paths, and so on
    • clean any new perl installation from your $HOME (move to safe place for sure)
    • in short, try return your environment into previous working state
  2. relog, (logout, login)

  3. repair your system perl. Thats mean,

    • read @Sam Varshavchik's answer
    • reinstall it from your distribution, using your package manager (5.10).
    • this step should overwrite the mess you caused.
    • test it !
    • don't continue until youre ensured, everything working right as before.

Lesson learned: never overwrite your system perl

  1. learning

  2. installing perlbrew

    • run the installation command \wget -O - http://install.perlbrew.pl | bash
    • should finished without errors
    • follow the instructions how to modify your startup file e.g. ~/.profile or such... (you need to add one line to the end)
    • check your ~/perl5/perlbrew/bin should contain prelbrew and patchperl
  3. relog

  4. setup new perl, run

    • perlbrew init #init environment
    • perlbrew available #show what perl you can install
    • perlbrew install 5.20.0 #will take few minutes - depends on your system speed
    • perlbrew install-cpanm
    • perlbrew list #check
    • perlbrew switch perl-5.20.0 #activate newly installed perl 5.20

Check your installation

  • in the ~/perl5/perlbrew/bin you should have 3 scripts: prelbrew , patchperl , cpanm
  • perl -v should return 5.20
  • type cpanm - should return ~/perl5/perlbrew/bin/cpanm

You're done.

  1. CPAN modules

You can install new modules with cpanm, like:

Check the ~/perl5/perlbrew/perls/perl-5.20.0/bin/ for new commands

You will need update your own perl script's shebang line to

#!/usr/bin/env perl

I hope don't forget anything, maybe other more experienced perl-gurus will add/edit/correct more.

Anyway, in the reality the steps 5,6,7 are much easier as sounds (by reading this) and could be done in few minutes.

Nissa
  • 4,636
  • 8
  • 29
  • 37
clt60
  • 62,119
  • 17
  • 107
  • 194
  • On rpm-based distributions I would not recommend cpanm as a means of installing Perl packages. rpm is the only way to go. I am stating this even though I could trivially build a new version of Perl, or any package, and install it myself (and I've done that in the past), without clobbering the system Perl. And even if I did clobber it, I could fix it. I am not bragging, I am making a point. rpm is there to save my ass, if I'm about to royally frak-up. No matter how e11t3 uberhacker someone might be, everyone makes mistakes, and rpm will keep me from wasting a whole weekend fixing a big mess. – Sam Varshavchik Sep 13 '14 at 15:21
  • 2
    @SamVarshavchik please, learn about perlbrew. The `cpanm` is local for the perlbrew, and the whole `perlbrew` is completly isolated from the system perl, (runs in own separated envorinment, in it's own directory tree) and plus, you don't need to be `root` to install it. If you're not root, can't owerwrite system perl nor in accident. Your comment is OK when someone uses `cpanm` for system-wide perl (as root, or with `--sudo`) - but this isn't the `perlbrew's` case. SO, _youre crying right, but on the wrong grave..._ ;) – clt60 Sep 13 '14 at 16:00
4

On rpm-based Linux distributions, you should never install system software manually, like this, by trying to compile and build it yourself. RHEL's package management tool, rpm, performs an important function of keeping track of dependencies between packages, and prevent package conflicts.

The errors you showed are precisely the symptoms of a corrupted system Perl installation, and rpm exists precisely to avoid this sort of thing happening. Manually building and installing random tarballs completely bypasses the safety net that rpm provides.

There's no cookie-cutter recipe for recovering from a corrupted system install of a critical system rpm like perl, but in general:

1) run "rpm -q" perl, this will show you the exact version of the perl rpm package that rpm thinks should be installed.

2) go to the RHEL installation media/directory, verify that it contains the same perl-.x86_64.rpm package. If you previously installed RHEL updates, it's possible that you already updated perl, so look for the version that rpm tells you have installed in the RHEL update directory, and verify that you have the correct rpm package.

3) Execute:

rpm -ivh --force perl-<version>.x86_64.rpm

This will reinstall the original perl RPM package that was previously installed. Your problem is not only that you have extra versions of perl installed, but that it's likely that some of your custom perl builds have clobbered the system perl package, and uninstalling them won't help, you have to reinstall the system perl.

4) In RHEL, many perl modules are installed as separate packages. The above process should be used to reinstall every perl rpm package that you have installed. Execute:

rpm -q -a | grep '^perl'

This will give you a list of all Perl packages you have installed. You will need to repeat this procedure for every Perl rpm package.

It's not a 100% guarantee that this will fix everything, there could be other things wrong too, but this is a good first step towards recovery.

Sam Varshavchik
  • 114,536
  • 5
  • 94
  • 148
  • tkx for your reply @Sam-Varshavchik ... seems I will have a long weekend! ... will certainly try this and post the results here after done. Just a question, at rpm/yum is there a way to list all packages that depends on perl ? ... I can see what perl depends to, but could not find a way to identify who depends on it Regards. – Renato Sep 13 '14 at 01:26
  • "rpm -e --test perl" -- it's going to be a long list. – Sam Varshavchik Sep 13 '14 at 02:04
0

What I have done:

From @Sam-Varshavchik answer:

  1. Found the previous perl rpm in my yum cache, and installed ... rpm -ivh --force perl-<version>.x86_64.rpm

  2. Checked for others "perl*" previously installed packages ... there were +260 so saved it in a file rpm -qa "perl*" > /tmp/perl.pkgs

  3. With +260 packages to install, I realized that do it manually would take too much time, so it was time to put some ksh skills in practice ...

    I checked at my yum cache and found ~130 of the +260 packages, so

    • took out from the list the base perl package (that I already have installed);
    • for those in the cache, I decided to install then with rpm, in the same way as the base package;
    • for those that I did not have handy, I used yum, which would download and do the same of rpm, so ...

    CACHE="/var/cache/yum/x86_64" for perlpkg in $(cat /tmp/perl.pkgs) do FILE=$(find $CACHE -name "${perlpkg}.rpm") if [[ ${FILE} != "" ]] ; then rpm -ivh --force ${FILE} else yum -y reinstall ${perlpkg} fi done

From @jm666:

  1. Installed perlbrew (was able to got it from my auth repos, so got it using yum) and using perlbrew, installed 5.20.0 localy

    • TODO: Didn't got any additional modules and neither Padre yet ... need to learn more about the way perlbrew works and isolate the installed version away from the system perl

Once again, thanks @Sam-Varshavchik and @jm666 for your support ang guidance

Renato
  • 161
  • 1
  • 13
  • I know nothing about the perlbrew installed by `yum`. The method in my answer installs the `perlbrew` _into your home directory_ . The default is `$HOME/perl5/perlbrew`. Later, the `perlbrew` installs new perl's (you can have _multiple_) into the directory `$HOME/perl5/perlbrew/perls/perl5.20.0` (by versions). In the 5.) you modifying your `.profile` by adding a line `source ~/perl5/perlbrew/etc/bashrc` - and this line allows you using the newly installed perl. **You don't need to be root, for installing perl with perlbrew**. e.g. you can't overwrite your system perl. – clt60 Sep 14 '14 at 19:05