Project

General

Profile

Actions

Feature #16975

closed

Warn when value from environment is being ignored by `Dir.tmpdir`

Added by deivid (David Rodríguez) over 3 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:98906]

Description

Currently, if you set ENV["TMPDIR"] to a value that doesn't meet Dir.tmpdir criteria to become the temporary folder, the environment variable is silently ignored and the next variable in the chain is checked.

This makes issues quite hard to debug, because the temporary folder can get silently set to a value you don't expect.

An example of this is: https://github.com/rubygems/rubygems/issues/3649.

And I believe some failures I run into in https://github.com/ruby/ruby/pull/3211 were caused by the same issue.

Would it be useful to replace the following "silent rescue" to introduce a warning when it's hit?

https://github.com/ruby/tmpdir/blob/b08fec48d5cef93ea3dbaa604c9e0b833f086dae/lib/tmpdir.rb#L30

I'm happy to create a PR if this is accepted.

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

I think it would be acceptable.
That "silent rescue" is actually for File.stat only, that is an obvious case.
I guess you may want to split the following conditions.

Updated by deivid (David Rodríguez) over 3 years ago

@nobu (Nobuyoshi Nakada) You are totally right, I misread the code. What we would need is indeed to split the following conditions.

Updated by deivid (David Rodríguez) about 3 years ago

I think @nobu (Nobuyoshi Nakada) fixed this at https://github.com/ruby/tmpdir/pull/7, so I'm closing this. Thanks!

I'd like to ask why issues were disabled at https://github.com/ruby/tmpdir.

Updated by deivid (David Rodríguez) about 3 years ago

Actually I don't think I have permissions to close the ticket, or at least I don't know how.

Actions #5

Updated by jeremyevans0 (Jeremy Evans) about 3 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0