Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError with pdm run and process substitution #3252

Closed
1 task done
ZeeD opened this issue Nov 4, 2024 · 2 comments · Fixed by #3260
Closed
1 task done

FileNotFoundError with pdm run and process substitution #3252

ZeeD opened this issue Nov 4, 2024 · 2 comments · Fixed by #3260
Assignees
Labels
🐛 bug Something isn't working

Comments

@ZeeD
Copy link

ZeeD commented Nov 4, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

have the following cat.py in a simple pdm project

from sys import argv

with open(argv[1]) as f:
    print(f.read())

I can execute the script with pdm run src/cat.py <myfile> successfully.

Actual behavior

It seems that process substitution is not supported:

$ pdm run src/cat.py <(echo foo)
Traceback (most recent call last):
  File "[OMISSIS]/src/cat.py", line 3, in <module>
    with open(argv[1]) as f:
         ^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/dev/fd/18'
$ 

Expected behavior

$ pdm run src/cat.py <(echo foo)
foo

$ 

NB: this is also the actual behavior calling directly the python intepreter:

$ .venv/bin/python src/cat.py <(echo foo)
foo

$ 

Environment Information

$ pdm info && pdm info --env
PDM version:
  2.20.0.post1
Python Interpreter:
 [OMISSIS]/.venv/bin/python (3.12)
Project Root:
  [OMISSIS]
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.12.4",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.11.4-amd64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Debian 6.11.4-1 (2024-10-20)",
  "python_full_version": "3.12.6",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "linux"
}
$ 
@ZeeD ZeeD added the 🐛 bug Something isn't working label Nov 4, 2024
@ZeeD
Copy link
Author

ZeeD commented Nov 4, 2024

I'm not 100% sure (and I haven't tested on pdm, just on some dummy scripts) but it should be enough to add close_fds=False to subprocess.Popen(...) in

process = subprocess.Popen(process_cmd, cwd=cwd, shell=shell, bufsize=0)

@ZeeD
Copy link
Author

ZeeD commented Nov 7, 2024

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants