conda / conda-package-handling

Create and extract conda packages of various formats
https://conda.github.io/conda-package-handling/
BSD 3-Clause "New" or "Revised" License
26 stars 37 forks source link

Delay os.getcwd() call to function body #243

Closed dholth closed 3 months ago

dholth commented 4 months ago

Description

Fix #205 (if caller passes output directory)

Checklist - did you ...

jaimergp commented 3 months ago

The change looks ok to me but I'm not sure why this fixes the mentioned issue 🤔 How can the cwd not exist? Or is it because it's being run in a volatile directory which by the time of execution has been deleted?

dholth commented 3 months ago

The change looks ok to me but I'm not sure why this fixes the mentioned issue 🤔 How can the cwd not exist? Or is it because it's being run in a volatile directory which by the time of execution has been deleted?

Yes, it is a weird error. Could it be interacting with the cwd's lack of thread safety? This is the best we can do in conda-package-handling; if the caller passes out_folder then we won't trigger the exception.

mkdir foo
cd foo
python3
# in a separate shell, rmdir foo
>>> import os
>>> os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
dholth commented 3 months ago

Thanks!