Skip Menu |
Report information

Subject: Should I be able to change the temporary directory?
From: brian d foy <brian.d.foy [...] gmail.com>
Date: Fri, 30 Dec 2016 03:34:11 -0500
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 3.1k
tmpdir doesn't appear to change directories. This is probably why I had the problem with https://rt.perl.org/Ticket/Display.html?id=130454 (although I should have had a different error there). It's not documented to do that in the various IO::Spec modules, but I was trying stuff in S16 to see what works. Should I be able to change the temporary directory as S16 says, or is it forever fixed and should be documented as read-only? my $dir = '/Users/brian'; my $dir-io = $dir.IO; put "$dir is a dir: " ~ $dir-io.d; put "$dir is readable: " ~ $dir-io.r; put "$dir is executable: " ~ $dir-io.x; put "$dir is writeable: " ~ $dir-io.w; tmpdir( $dir ) It looks like everything should work, but it doesn't: /Users/brian is a dir: True /Users/brian is readable: True /Users/brian is executable: True /Users/brian is writeable: True Cannot modify an immutable IO::Path in block <unit> at /Volumes/Big Scratch/Dropbox/~~Writing/Perl Writing/LearningPerl6/learning_perl_6/scratch/file_trials.p6 line 11 Or, assigning to it directly: my $dir = '/Users/brian'; my $dir-io = $dir.IO; put "$dir is a dir: " ~ $dir-io.d; put "$dir is readable: " ~ $dir-io.r; put "$dir is executable: " ~ $dir-io.x; put "$dir is writeable: " ~ $dir-io.w; $*TMPDIR = $dir; It says I can't assign to $*TMPDIR. How is it that I can't assign to dynamic variable? What's the point of it being dynamic if it can't change? Cannot modify an immutable IO::Path in block <unit> at /Volumes/Big Scratch/Dropbox/~~Writing/Perl Writing/LearningPerl6/learning_perl_6/scratch/file_trials.p6 line 11 Try it with my: my $dir = '/Users/brian'; my $dir-io = $dir.IO; put "$dir is a dir: " ~ $dir-io.d; put "$dir is readable: " ~ $dir-io.r; put "$dir is executable: " ~ $dir-io.x; put "$dir is writeable: " ~ $dir-io.w; my $*TMPDIR; tmpdir( $dir ) Now it's a different sort of error. This kinda makes sense because there's nothing in $*TMPDIR and tmpdir expects IO::Spec. But why is the error in chdir and not something that catches that the argument wasn't IO::Spec? /Users/brian is a dir: True /Users/brian is readable: True /Users/brian is executable: True /Users/brian is writeable: True No such method 'chdir' for invocant of type 'Any' in block <unit> at /Volumes/Big Scratch/Dropbox/~~Writing/Perl Writing/LearningPerl6/learning_perl_6/scratch/file_trials.p6 line 13 Use temp instead, and it's a different error (despite that temp was used for this purpose in S16): my $dir = '/Users/brian'; my $dir-io = $dir.IO; put "$dir is a dir: " ~ $dir-io.d; put "$dir is readable: " ~ $dir-io.r; put "$dir is executable: " ~ $dir-io.x; put "$dir is writeable: " ~ $dir-io.w; temp $*TMPDIR; tmpdir( $dir ) Now it's a different sort of error: /Users/brian is a dir: True /Users/brian is readable: True /Users/brian is executable: True /Users/brian is writeable: True Can only use 'temp' on a container in block <unit> at /Volumes/Big Scratch/Dropbox/~~Writing/Perl Writing/LearningPerl6/learning_perl_6/scratch/file_trials.p6 line 11


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org