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

poetry self update issues with new installer #4146

Closed
3 tasks done
13steinj opened this issue Jun 5, 2021 · 4 comments
Closed
3 tasks done

poetry self update issues with new installer #4146

13steinj opened this issue Jun 5, 2021 · 4 comments

Comments

@13steinj
Copy link

13steinj commented Jun 5, 2021

  • 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 (-vvv option).
  • OS version and name: Windows 10
  • Poetry version: 1.1.6
  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

Decided to install poetry. No idea if I already had an installation or not (recovered machine from old backup) but poetry was not working so I assumed not. Followed instructions on python-poetry.org. During the installation, found that the installation script was out of date. Cancel installation with SIGTERM via Ctrl-C (if this doesn't rollback installation, it should, or at least not leave the system in a broken state).

Decided to install via the new install-poetry.py script. Everything seemed dandy. Added poetry to my path as instructed.

Immediately, just in case, I tested poetry self update. I got two different results depending on if I was using git-bash or windows powershell.

In Powershell, I got this error (shown with -vvv)

  Stack trace:

  5  c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\console_application.py:131 in run
      129│             parsed_args = resolved_command.args
      130│
     131│             status_code = command.handle(parsed_args, io)
      132│         except KeyboardInterrupt:
      133│             status_code = 1

  4  c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py:120 in handle
      118│     def handle(self, args, io):  # type: (Args, IO) -> int
      119│         try:
     120│             status_code = self._do_handle(args, io)
      121│         except KeyboardInterrupt:
      122│             if io.is_debug():

  3  c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py:171 in _do_handle
      169│         handler_method = self._config.handler_method
      170│
     171│         return getattr(handler, handler_method)(args, io, self)
      172│
      173│     def __repr__(self):  # type: () -> str

  2  c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\cleo\commands\command.py:92 in wrap_handle
       90│         self._command = command
       91│
      92│         return self.handle()
       93│
       94│     def handle(self):  # type: () -> Optional[int]

  1  c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\self\update.py:86 in handle
       84│         from poetry.repositories.pypi_repository import PyPiRepository
       85│
      86│         self._check_recommended_installation()
       87│
       88│         version = self.argument("version")

  RuntimeError

  Poetry was not installed with the recommended installer. Cannot update automatically.

  at c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\self\update.py:248 in _check_recommended_installation
      244│         current = Path(__file__)
      245│         try:
      246│             current.relative_to(self.home)
      247│         except ValueError:
     248│             raise RuntimeError(
      249│                 "Poetry was not installed with the recommended installer. "
      250│                 "Cannot update automatically."
      251│             )
      252│

On git bash, I received an entirely different error (I'm assuming it was actually the same error, however on top of this some character that you're using to generate the output is causing encoding issues).

  Stack trace:

  5  c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\console_application.py:131 in run
Traceback (most recent call last):
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\self\update.py", line 246, in _check_recommended_installation
    current.relative_to(self.home)
  File "C:\Program Files\Python\Python SDK 3.9.5\lib\pathlib.py", line 929, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: 'c:\\users\\[redacted]\\appdata\\roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\console\\commands\\self\\update.py' is not in the subpath of 'C:\\Users\\[redacted]\\.poetry' OR one path is relative and the other is absolute.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\cleo\commands\command.py", line 92, in wrap_handle
    return self.handle()
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\self\update.py", line 86, in handle
    self._check_recommended_installation()
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\self\update.py", line 248, in _check_recommended_installation
    raise RuntimeError(
RuntimeError: Poetry was not installed with the recommended installer. Cannot update automatically.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python\Python SDK 3.9.5\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python\Python SDK 3.9.5\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\[Redacted]\AppData\Roaming\Python\Scripts\poetry.exe\__main__.py", line 7, in <module>
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\poetry\console\__init__.py", line 5, in main
    return Application().run()
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\console_application.py", line 142, in run
    trace.render(io, simple=isinstance(e, CliKitException))
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 232, in render
    return self._render_exception(io, self._exception)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 257, in _render_exception
    self._render_trace(io, inspector.frames)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 381, in _render_trace
    self._render_line(
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\ui\components\exception_trace.py", line 402, in _render_line
    io.write_line("{}{}".format(indent * " ", line))
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\cleo\io\io_mixin.py", line 65, in write_line
    super(IOMixin, self).write_line(string, flags)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\api\io\io.py", line 66, in write_line
    self._output.write_line(string, flags=flags)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\api\io\output.py", line 69, in write_line
    self.write(string, flags=flags, new_line=True)
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\api\io\output.py", line 61, in write
    self._stream.write(to_str(formatted))
  File "c:\users\[redacted]\appdata\roaming\pypoetry\venv\lib\site-packages\clikit\io\output_stream\stream_output_stream.py", line 24, in write
    self._stream.write(string)
  File "C:\Program Files\Python\Python SDK 3.9.5\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2502' in position 27: character maps to <undefined>

So clearly, there's some kind of conflict somewhere, given the mention of a ~/.poetry directory which doesn't exist. Which means either

  • update.py doesn't know where it's supposed to be (thinks it is in the wrong place) and is causing this issue
    • but I can't find anything here...
  • I have borked my install beyond compare and don't know what to do in order to fix it

Here's the big problem... I know Python, and this current = Path(__file__) implies that current should be the path to the update script in the correct location...but isn't. Which means either

  • there's some super weird caching going on
  • something in poetry is mucking with __file__

To test this, I manually edited that code to print out __file__ on error, and, well,

__file__='c:\\users\\[redacted]\\appdata\\roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\console\\commands\\self\\update.py'
self.home=WindowsPath('C:/Users/[redacted]/.poetry')

Digging around the code, self.home is based on POETRY_PATH. Which means either

  • things are installing to the wrong location for some reason
  • my POETRY_PATH should be set during the installation process, but it wasn't.
@13steinj 13steinj added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 5, 2021
@13steinj
Copy link
Author

13steinj commented Jun 5, 2021

Note: I manually redacted my username and replaced it with [redacted] for personal reasons. In retrospect I should have just replaced it with "steinj13" since that's roughly equivalent to my github username, but I'm tired and didn't sync it in my head.

@abn
Copy link
Member

abn commented Jun 5, 2021

@13steinj I suspect you would have seen this during your installation

poetry/install-poetry.py

Lines 428 to 433 in 925429f

colorize(
"warning",
f"You are installing {version}. When using the current installer, this version does not support "
f"updating using the 'self update' command. Please use 1.2.0a1 or later.",
)
)

Python versions prior to 1.2.x installed via the (in-preview) install-poetry.py script will not be able to perform self-update as the install mechanisms are quite different. You can use the --preview flag to get the latest preview release.

See also: #4040 (comment)

@abn abn closed this as completed Jun 5, 2021
@abn abn added Installer and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 6, 2021
@13steinj
Copy link
Author

13steinj commented Jun 9, 2021

@abn Perhaps I got that message and didn't notice, odd.

Though I fail to understand something here-- the official documentation on the website says the installer you should use is get-poetry.py

Running this installer, however, tells you you aren't using the recommended installer and to use install-poetry.py.

If I don't want to use the preview version, because I'm not a fan of alpha relesses, which script do I use? Will I then when 1.2.0 releases be able to use self update? Or at minimum, be able to somehow migrate from 1.1.x to 1.2.0 and then from that point on be able to use self update?

Poetry is great software, but upgrading and installing shouldn't be so convoluted. It turns people away from using it in the first place. I don't know the details behind the change in installation script, directory, etc, but currently installing poetry from scratch is a bit of a mess in what one has to do and where one has to go in order to do it.

Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants