Windows 10 Home: test failure in t/from_file.t: could not create temp file: Permission denied
Closed this issue · 9 comments
I could not install ack 2 due to a problem in File::Next due to failure (t/from_file.t) in creating temp file via File::Temp->new. The output of failure is same as reported by Roy I in ...
http://www.cpantesters.org/cpan/report/bd6bc48b-6c4b-1014-bc90-c38f497dc0be
... I am using Strawberry Perl 5.24.0 64-bit. I had tried to install in Windows PowerShell.
I have lost interest due to no response, so closing it.
I'm sorry, I didn't have anything to respond. I don't have any Windows machines, so rely on others to help out on Windows issues. If you have any insight as to what the problem is, I'd love to hear it.
Thanks
The error
Error in tempfile() using template \XXXXXXXXXX: Could not create temp file \IZy8unsm8B: Permission denied at t/from_file.t line 79.
is caused by File::Temp->new()
, which calls
File::Spec->catfile(File::Spec->tmpdir, 'X' x 10);
File::Spec::Win32::tmpdir
returns the first writeable temporary directory from a list which includes the directories pointed by environment variables TMPDIR
, TEMP
, TMP
, and some default directories like 'c:/temp'
and '/'
. Somehow in the platform where the error happens, -w '/'
returns true but creating a file in '/'
fails.
The reported failure is therefore caused by File::Spec::Win32::tmpdir
and not by File::Next
. The fix should be in File::Spec::Win32::tmpdir
.
A workaround might be to define the TMP
environment variable to a writeable directory.
This issue should be closed.
@Parv Have you tried changing TMP
to a different directory that you verify is writeable? What happened?
Thanks @pauloscustodio for the details.
@petdance I am just as blind w.r.t. Windows as you are, for I have only recently started Perl use here. Thanks for the explanation about the delay.
Both of $env:TMP and $env:TEMP were/are indeed set to a directory writable by me. $env:TMPDIR is not set. If I should somehow pass the value during "perl Makefile.PL" or "dmake Makefile", please let me know the syntax to use.
In any case, after verifying that $env:TE?MP was writable, I had tried again to install F::N, but failed for the same reason. I had also tried setting the the three variables ("dmake all|test (TE?MP|TMPDIR)=C:/Users/parv/AppData/Local/Temp") thus ...
dmake all TMP=C:/Users/parv/AppData/Local/Temp
dmake test TMP=C:/Users/parv/AppData/Local/Temp
.
.. same failure.
OTOH if the problem is in File::Spec per @pauloscustodio , I will file bug/followup there; I think closing this one would be justifiable.
Why not try it with TMPDIR
set to a directory, too?
I tried to run install F::N via cpan after setting the $Env:TMPDIR ...
PS C:\Users\parv> [Environment]::SetEnvironmentVariable( 'TMPDIR' ,
$env:TEMP )
PS C:\Users\parv> Get-ChildItem Env:TMPDIR
Name Value
---- -----
TMPDIR C:\Users\parv\AppData\Local\Temp
... but the same test still failed for the same reason. Let me know please if there is anything else to try.
The issue is caused by -T
in the shebang of from_file.t
. Is there any reason to keep it? Removing it would be the simplest fix.
Environmental variables (like TEMP
) are tainted, so File::Spec
has to fallback to the following list:
C:\system\temp
C:/temp
/tmp
/
One possible workaround is to create C:\temp
directory.
I am sorry for the late reply.
After creating C:\temp, as @xenu mentioned, test passes (fails when it is gone). WRT this bug report, I am satisfied that problem could be worked-around.
Thank you all the people involved.
(Maintainer of File::Temp: Microsoft by default does not supply C:\TEMP in Windows 10 ("Home", if that matters). There is certainly C:\$USER\TEMP.)