bugGNU Octave - Bugs: bug #63728, tempname() respects the TMP...

 
 

bug #63728: tempname() respects the TMP environment variable and tempdir() does not

Submitter:  None
Submitted:  Mon 30 Jan 2023 12:24:39 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 7.3.0
Operating System:  * GNU/Linux Fixed Release:  8.1.0
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 31 Jan 2023 07:10:16 AM UTC, comment #4: 

Thank you for checking with Octave 8.

Since the used temporary directory seems to be consistent now, I'm closing this report as fixed.

Markus Mützel <mmuetzel>
Group administrator
Mon 30 Jan 2023 11:17:55 PM UTC, comment #3: 

comment #1:

> snip
>
> ISTR that there were some changes regarding the used temporary directory for Octave 8.
> Do you still see that inconsistency with (the release candidate of) Octave 8?
>


Thanks for the hint! Seems ok in Octave 8:

$ unset TMP TMPDIR
$
$ octave -f p.m
tempdir: /tmp/
tempname: /tmp/oct-qADTgN
P_tmpdir: /tmp
$
$ env TMP=/tmp/new-tmp octave -f p.m
tempdir: /tmp/new-tmp/
tempname: /tmp/new-tmp/oct-BwAUu8
P_tmpdir: /tmp
$
$ env TMPDIR=/tmp/new-tmp octave -f p.m
tempdir: /tmp/new-tmp/
tempname: /tmp/new-tmp/oct-5HuVZ6
P_tmpdir: /tmp
$
$ cat p.m
printf ("tempdir: %s\n", tempdir ());
printf ("tempname: %s\n", tempname ());
printf ("P_tmpdir: %s\n", P_tmpdir ());
$


Octave version:

$ cat .hg_archival.txt
repo: 22412e3a4641782b0dc45cf256bceb9c3984b154
node: f812dd8304d982e09c48a2cc688a3a36127500d0
branch: default
latesttag: rc-8-0-90
latesttagdistance: 21





This problem has been fixed in the development version. The fix
will be available in the next major software release. Thank you
for your bug report.

Anonymous
Mon 30 Jan 2023 06:57:46 PM UTC, comment #2: 

The whole issue of temporary names is confusing and should probably just be re-architected in Octave.  I used this script to test (attached as print_tmp.m):


printf ("tempdir: %s\n", tempdir ());
printf ("tempname: %s\n", tempname ());
printf ("P_tmpdir: %s\n", P_tmpdir ());


I then run with


octave-7.3.0 -f print_tmp.m


so that I am sure of the Octave version and also sure that any .octaverc files are not changing the results.

As reported, tempdir() does not follow tempname() in choice of directory.

In terms of coding, Octave is showing some of its UNIX heritage.  The function "P_tmpdir" returns the default system temporary directory (not influenced by user's environment variables).  If we really need to have this function (I don't know, but it could be important for build/testing situations where we don't want the user's environment to affect results) then I think it should be renamed to something more friendly (maybe, "sys_tempdir"?) rather than the opaque, CamelCase name "P_tmpdir".  If we don't need it then I would just remove it from Octave completely.

Next, I would have tempdir() respect TMPDIR, TMP, and TEMP environment variables.  Once that modification was done then tempname() could be modified to just use tempdir() to determine the directory.

As it is now, the Octave interpreter is calling out to liboctave for system functions which in turn are coded in C and used via wrappers to gnulib.  That seems hard.


(file #54290)

Rik <rik5>
Group administrator
Mon 30 Jan 2023 04:46:41 PM UTC, comment #1: 

On Windows (where TEMP is used in place of TMP), I see the following with the release candidate for Octave 8.0.90:

>> getenv('TEMP')
ans = C:\Users\Markus\AppData\Local\Temp
>> getenv('TMPDIR')
ans =
>> tempname()
ans = C:\Users\Markus\AppData\Local\Temp\oct-cD62Ae
>> tempdir()
ans = C:\Users\Markus\AppData\Local\Temp\
>> setenv('TMPDIR', 'C:\Temp')
>> tempname()
ans = C:\Temp\oct-jUBCA8
>> tempdir()
ans = C:\Temp\
>> unsetenv('TMPDIR')
ans = 0
>> setenv('TEMP', 'C:\Temp')
>> tempdir()
ans = C:\Temp\
>> tempname()
ans = C:\Temp\oct-YaQ5Uh


That seems more consistent.

ISTR that there were some changes regarding the used temporary directory for Octave 8.
Do you still see that inconsistency with (the release candidate of) Octave 8?

Markus Mützel <mmuetzel>
Group administrator
Mon 30 Jan 2023 12:24:39 AM UTC, original submission:  


$ unset TMP TMPDIR
$
$ ./t.m
ans = /tmp/oct-GypSGw
ans = /tmp/
$
$ env TMP=/tmp/new-tmp ./t.m
ans = /tmp/new-tmp/oct-q3bOs4
ans = /tmp/
$
$ env TMPDIR=/tmp/new-tmp ./t.m
ans = /tmp/new-tmp/oct-4pJLYK
ans = /tmp/new-tmp/
$
$ cat t.m
#!/usr/bin/env octave

tempname()
tempdir()
$


This causes some tests to fail.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #54290:  print_tmp.m added by rik5 (118B - text/x-matlab)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-31 mmuetzel Open/ClosedOpen Closed
    2023-01-31 mmuetzel StatusConfirmed Fixed
        Fixed ReleaseNone 8.1.0
    2023-01-30 rik5 StatusNeed Info Confirmed
    2023-01-30 rik5 Attached File- Added print_tmp.m, #54290
    2023-01-30 mmuetzel StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code