PGTS PGTS Pty. Ltd.   ACN: 007 008 568

point Site Navigation

point Other Blog Threads

  Valid HTML 4.01 Transitional

   Download Kubuntu Today


   The Power Of KDE + Ubuntu

PGTS Humble Blog

Thread: Perl Programming

Author Image Gerry Patterson. The world's most humble blogger
Some folks are born, silver spoon in hand ... Creedence Clearwater

Problems With YAML

Chronogical Blog Entries:

Date: Mon, 05 Jan 2009 02:11:00 +1100

Recently I tried running cpan on an Ubuntu workstation.

Whenever I tried to download a module I got the following error:
CPAN: YAML loaded ok (v0.66)
Alert: While trying to 'parse' YAML file
with 'YAML' the following error was encountered:
  YAML Error: Invalid element in map
   Line: 3
   Document: 1
 at /usr/local/share/perl/5.8.8/ line 33

I tried reloading cpan, but when cpan tried to fetch the CPAN module the same error occurred.

Next I tried looking at the YAML code. This didn't really tell me much.
sub Load {
    my $yaml = YAML->new;
        if $YAML::LoaderClass;
    return $yaml->loader_object->load(@_); # <-- Error occured here

I tried looking at the file in /root/.cpan/FTPstats.yml, but that made even less sense to me.

The apocryphal tale about YAML is that it was renamed from Yet Another Markup Language to the more geeky YAML Ain't no Markup Language (could your humble blogger suggest: Yet Another recursive acronyM Laddie). Well, I certainly ain't no expert on YAML, and frankly I have no wish to become one. YAML is often used to maintain configuration data, and AFAIK its raison d'etre is parsing lists. It may be inextricably embroiled with the CPAN configuration file, which is called on most perl distributions. In Ubuntu the system wide config file is kept in this location:


You will need to be an administrator to edit this file. If you don't feel comfortable about editing it (and in my humble opinion you would have to be either a perl guts guru or a bit crazy to try it) then you can edit the files with your favourite editor. I would suggest removing the config files and config folder file. I used the following code:
sudo -i
mv /etc/perl/CPAN/ /etc/perl/CPAN/
mv /root/.cpan /root/.cpan.old

This enables you to keep an old copy of the config file, and any old data in the .cpan folder (just in case they contained something valuable). Now, if you run CPAN again you will be lead through the configuration dialogue. If you have a copy of (e.g. from another Ubuntu workstation in the same local network), you can copy it to the /etc/perl/CPAN On the other hand if you know what the problem is you can edit the files with vi or emacs and make the appropriate changes (but as already stated, you really MUST know what you are doing if you edit these files).

In my case I found that getting rid of both the and .cpan folder fixed the problem. After CPAN had been re-configured everything worked ok.

You might want to try entering these two commands:

	install Bundle::CPAN
	reload cpan

Note: If you are a Windows user (you shouldn't even be reading this), you would be ill-advised to do this -- I suggest you try removing Activestate perl, reinstalling it and rebooting your machine (and maybe consider getting a decent operating system for your computing environment).

Note: (Unix users) If everything works ok -- DON'T FORGET to enter this command:

	o conf commit
BEFORE you quit (unless of course you set the autocommit option as part of the configuration dialogue).

Other Blog Posts In This Thread:

Copyright     2009, Gerry Patterson. All Rights Reserved.