-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: Windows 10
- Poetry version: 1.0.0b1
- Link of a Gist with the contents of your pyproject.toml file:
Issue
Cannot use Python interpreter at "C:\Program Files\Python38\python.exe", because Poetry makes a subprocess call using shell without properly quoting arguments. Note that, while I found this issue in Windows, any operating system is affected. It's just that spaces in paths are not so common in other systems. The above path is the default installation folder of Python for Windows when installed for all users.
>poetry env use -vvv "C:\Program Files\Python38\python.exe"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
[EnvCommandError]
Command C:\Program Files\Python38\python.exe -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 1, and output:
Traceback (most recent call last):
File "C:\Users\asassi\.poetry\lib\poetry\_vendor\py3.6\clikit\console_application.py", line 132, in run
status_code = command.handle(parsed_args, io)
File "C:\Users\asassi\.poetry\lib\poetry\_vendor\py3.6\clikit\api\command\command.py", line 119, in handle
status_code = self._do_handle(args, io)
File "C:\Users\asassi\.poetry\lib\poetry\_vendor\py3.6\clikit\api\command\command.py", line 167, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "C:\Users\asassi\.poetry\lib\poetry\_vendor\py3.6\cleo\commands\command.py", line 92, in wrap_handle
return self.handle()
File "C:\Users\asassi\.poetry\lib\poetry\console\commands\env\use.py", line 24, in handle
env = manager.activate(self.argument('python'), poetry.file.parent, self._io)
File "C:\Users\asassi\.poetry\lib\poetry\utils\env.py", line 177, in activate
raise EnvCommandError(e)
Simply removing the " ".join and shell=True from https://github.com/sdispater/poetry/blob/master/poetry/utils/env.py#L185 and other subprocess calls throughout this file, and possibly in many other files, should fix this issue.
Poetry should always use the argument list form (without shell=True) to call subprocesses, which has no ambiguity or other issues with escaping special characters.