Skip Menu |

Subject: tmpdir tries to change the current working directory
Date: Fri, 30 Dec 2016 02:10:31 -0500
To: rakudobug [...] perl.org
From: brian d foy <brian.d.foy [...] gmail.com>
Setting the temporary directory apparently tries to change the current working directory, which I didn't expect. But, the documentation for tmpdir doesn't say what it does (https://docs.perl6.org/routine/tmpdir). put "Tempdir is " ~ $*TMPDIR; { my $dir = '/Users/brian/.tmp'; unless my $rc = tmpdir( '/Users/brian/.not_there' ) { my $e = $rc.exception; put "unless: Error changing to $dir " ~ $e.^name ~ ': ' ~ $e.message; } CATCH { put "CATCH: Error changing to $dir " ~ .^name; } } I expected that tmpdir would return a Failure, and maybe it does if it doesn't change the current working directory. This may be related to https://rt.perl.org/Ticket/Display.html?id=130418 ("chdir appears to throw exception immediately"). I would only expect things that want to create a temporary file to use the value of TMPDIR (say, like https://github.com/perlpilot/p6-File-Temp). I don't need to know where that is and wouldn't want the current working directory to be there. I'd rather have the current working directory be the one where my input files are.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.2k
On Thu, 29 Dec 2016 23:11:38 -0800, comdog wrote: Show quoted text
> Setting the temporary directory apparently tries to change the current > working directory, which I didn't expect. But, the documentation for > tmpdir doesn't say what it does > (https://docs.perl6.org/routine/tmpdir). > > put "Tempdir is " ~ $*TMPDIR; > > { > my $dir = '/Users/brian/.tmp'; > unless my $rc = tmpdir( '/Users/brian/.not_there' ) { > my $e = $rc.exception; > put "unless: Error changing to $dir " ~ $e.^name ~ ': ' ~ > $e.message; > } > CATCH { > put "CATCH: Error changing to $dir " ~ .^name; > } > } > > I expected that tmpdir would return a Failure, and maybe it does if it > doesn't change the current working directory. This may be related to > https://rt.perl.org/Ticket/Display.html?id=130418 > ("chdir appears to throw exception immediately"). > > I would only expect things that want to create a temporary file to use > the value of TMPDIR (say, like > https://github.com/perlpilot/p6-File-Temp). I don't need to know where > that is and wouldn't want the current working directory to be there. > I'd rather have the current working directory be the one where my > input files are.
Thank you for the report. &tmpdir was removed from Rakudo's implementation and the issue described in this ticket no longer applies. -- IO grant


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