You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running into an issue where if I provide a command that has a full path for an executable, for example: "C:\Program Files\Java\jdk-21\bin\java.exe"
It fails to load giving a FileNotFoundError. After investigating the spawn code I found it tries to find the executable in the PATH env variable. While testing the issue, I modified the environment variable PATH to include the location of the executable but this still failed.
To resolve the issue I commented out lines 79-87 of ptyprocess.py:
path = env.get('PATH', os.defpath)
command_with_path = which(command, path=path)
if command_with_path is None:
raise FileNotFoundError(
'The command was not found or was not ' +
'executable: %s.' % command
)
command = command_with_path
argv[0] = command
I am not sure the spawn code should be testing paths against the environment variable PATH and should be left to the code that is calling spawn. This gives more flexibility and also behaves more closely to the subprocess.Popen would. After commenting out this code everything was working as expected.
Another option to the environment PATH testing is if the "which" call returns None, perhaps a call to os.path.exists(command) or os.path.isfile(command) to verify the file exists.
Depending on how you would like the spawn function to behave, I would be glad to create a pull request.
The text was updated successfully, but these errors were encountered:
I am running into an issue where if I provide a command that has a full path for an executable, for example: "C:\Program Files\Java\jdk-21\bin\java.exe"
It fails to load giving a FileNotFoundError. After investigating the spawn code I found it tries to find the executable in the PATH env variable. While testing the issue, I modified the environment variable PATH to include the location of the executable but this still failed.
To resolve the issue I commented out lines 79-87 of ptyprocess.py:
I am not sure the spawn code should be testing paths against the environment variable PATH and should be left to the code that is calling spawn. This gives more flexibility and also behaves more closely to the subprocess.Popen would. After commenting out this code everything was working as expected.
Another option to the environment PATH testing is if the "which" call returns None, perhaps a call to os.path.exists(command) or os.path.isfile(command) to verify the file exists.
Depending on how you would like the spawn function to behave, I would be glad to create a pull request.
The text was updated successfully, but these errors were encountered: