When sudo Attacks!

The other day I was installing a CPAN module and I was doing it the normal way:

sudo perl -MCPAN -e "install ModuleName"

And it didn’t install — I got a GPG permission error[1].  It seemed odd.  I tried it a few times and that didn’t work.   So I tried to upgrade CPAN.  And I got the same error!  I was bedudled. So then I downloaded and compiled the latest GnuPG.  But I got the same thing!

And then it hit me.   I was running Perl under sudo.  So when it ran gpg it was running it as root but still trying to get to my keystore under ~/mikeh/.gnupg, where it didn’t have permission to read.  So this time I did:

sudo su -  perl -MCPAN -e "install ModuleName"

And it worked like a charm.

I’ve used sudo a lot to install CPAN modules before, but I guess I never tried installing one that required a gpg signature check.

[1]  Sorry for not having the exact error.  That’s what happens when I don’t blog right away.

Leave a Reply

You must be logged in to post a comment.