Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

cpan problems when /tmp and /var are existing symbolic links

by PhilipS (Novice)
on Jan 22, 2019 at 23:19 UTC ( [id://1228850]=perlquestion: print w/replies, xml ) Need Help??

PhilipS has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to install modules from cpan on a machine where /tmp is an existing symbolic link. So Archive::Zip fails with "Could not extract xxx safely: /tmp is an existing symbolic link."

(I get the same issue with /var if I try to make/test/install manually. And I don't have permissions to change the symbolic links on that machine.)

Is there a workaround? I don't see any easy way to tell cpan to use a different directory as a temporary directory.

Thanks,
Philip

  • Comment on cpan problems when /tmp and /var are existing symbolic links

Replies are listed 'Best First'.
Re: cpan problems when /tmp and /var are existing symbolic links
by davido (Cardinal) on Jan 23, 2019 at 08:39 UTC

    I believe the tests for Archive::Zip utilize File::Temp, which discovers the tempdir using File::Spec. File::Spec suggests you can hint an alternate tempdir by setting the TMPDIR environment variable. Proof of concept:

    1. In your homedir create a directory named ~/tmp
    2. Execute TMPDIR=~/tmp perl -MFile::Spec::Functions=tmpdir -E 'say tmpdir()'

    You will see your alternate tempdir returned. This is what Archive::Zip should actually use.

    So you could possibly do this:

    TMPDIR=~/tmp cpanm Archive::Zip

    And if that doesn't work, built it yourself by downloading the archive from CPAN, extracting it to a directory, then:

    perl Makefile.PL make TMPDIR=~/tmp make test make install

    ...or just cpanm -f, but those tests for linkdir do exist for a reason. ;)


    Dave

Re: cpan problems when /tmp and /var are existing symbolic links
by Corion (Patriarch) on Jan 23, 2019 at 09:35 UTC

    CPAN uses Archive::Zip which uses File::Temp. There, $ENV{TMPDIR} is suggested to set up a writable temp directory. Maybe this works on your system.

Re: cpan problems when /tmp and /var are existing symbolic links
by afoken (Chancellor) on Jan 23, 2019 at 08:25 UTC

    Can you show the output of o conf entered into the cpan prompt? I don't think cpan should even try to extract files to /tmp, unless it was configured to do so.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      I watched /tmp on my computer while doing the make, make test dance and saw that it's the tests that tinker around inside /tmp. Skimming through the scripts in t/ confirmed this.


      Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1228850]
Approved by Athanasius
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found