harper25 / poetry-poems

Poetry Environment Switcher. Navigates to Poetry-based projects and activates Poetry shell.
https://poetry-poems.readthedocs.io/en/latest
GNU Lesser General Public License v3.0
1 stars 1 forks source link

Poems failing to start on Windows #8

Closed pjarnhus closed 3 years ago

pjarnhus commented 3 years ago

Describe the bug When running poems on Windows, the program exists with a FileNotFoundError. When digging into this, it is because the POpen calls have been set with shell=False. On Windows this will make subprocess interpret the elements of the cmd list literally and it will therefore look for a file called poetry.

To Reproduce Steps to reproduce the behavior:

  1. Install poems on Windows
  2. Run poems
  3. See error Traceback (most recent call last): File "c:\users\phrj\miniconda3\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\phrj\miniconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\phrj\Miniconda3\Scripts\poems.exe__main.py", line 7, in File "c:\users\phrj\miniconda3\lib\site-packages\click\core.py", line 829, in call return self.main(args, kwargs) File "c:\users\phrj\miniconda3\lib\site-packages\click\core.py", line 782, in main rv = self.invoke(ctx) File "c:\users\phrj\miniconda3\lib\site-packages\click\core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "c:\users\phrj\miniconda3\lib\site-packages\click\core.py", line 610, in invoke return callback(args, *kwargs) File "c:\users\phrj\miniconda3\lib\site-packages\click\decorators.py", line 21, in new_func return f(get_current_context(), args, **kwargs) File "c:\users\phrj\miniconda3\lib\site-packages\poetry_poems\cli.py", line 72, in poems poetry_config = PoetryConfig() File "c:\users\phrj\miniconda3\lib\site-packages\poetry_poems\poetry.py", line 58, in init self.call_poetry_virtualenvs_path() File "c:\users\phrj\miniconda3\lib\site-packages\poetry_poems\poetry.py", line 61, in call_poetry_virtualenvs_path output, code = PipedPopen(cmds=["poetry", "config", "virtualenvs.path"]) File "c:\users\phrj\miniconda3\lib\site-packages\poetry_poems\poetry.py", line 10, in PipedPopen proc = Popen(cmds, stdout=PIPE, stderr=PIPE, env=env, **kwargs) File "c:\users\phrj\miniconda3\lib\subprocess.py", line 854, in init__ self._execute_child(args, executable, preexec_fn, close_fds, File "c:\users\phrj\miniconda3\lib\subprocess.py", line 1307, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified

Expected behavior The expected behaviour is that poems launches and presents a list of the added poetry projects

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

Additional context Add any other context about the problem here.

pjarnhus commented 3 years ago

I have opened a pull request with the changes that makes it run on Windows, if you are interested. The test suite fails on setup due to the same underlying issue, but I have not had the time to clean it up.

Let me know, if you are interested in collaborating on it. I think it is a really cool tool, that you have built.

harper25 commented 3 years ago

Hi, @pjarnhus, great to hear from you, thanks for the issue, contribution and kind words. Of course I am interested in solving this issue and collaboration.

I tested the current version of the app on Win10 and also found some issues, but they are a bit different (I will post some screens). Several questions:

Screens from my testing, Windows 10 Home, 20H2.

  1. Command Prompt - OK obraz

  2. Cmder - details not correct, also issues on left/right arrow on poems interactive screen obraz

  3. Mingw (Git Bash here) - not working, details not correct, also issues on left/right arrow on poems interactive screen obraz

pjarnhus commented 3 years ago

Hi,

Sorry for the long period of silence, there has been a lot on my plate recently. I did test it out and it is working on the rebuild version with changes. I am using an Anaconda prompt, which as far as I know is simply a normal Windows command prompt with a few additions.

It is odd that I get the error, when your command prompt is working. My installation does not add python to the Windows path. I am not sure, if that is the reason behind the error though.

harper25 commented 3 years ago

Resolved in: https://github.com/harper25/poetry-poems/pull/9