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

topgrade errors on the poetry step #1021

Open
2 of 6 tasks
tsvikas opened this issue Jan 24, 2025 · 3 comments · May be fixed by #1028
Open
2 of 6 tasks

topgrade errors on the poetry step #1021

tsvikas opened this issue Jan 24, 2025 · 3 comments · May be fixed by #1028
Labels
C-bug Something isn't working

Comments

@tsvikas
Copy link

tsvikas commented Jan 24, 2025

Erroneous Behavior

When running topgrade, the poetry step raise an error at the poetry step (fedora 41, poetry is installed with dnf).

The debug log shows that the detected interpreter is suspicious - it got a space before and a parameter after

Expected Behavior

No fail, just output that poetry from dnf cannot self update

Steps to reproduce

I just ran topgrade, but I maybe some unknown setup of my system might affect it?

Possible Cause (Optional)

Seems like the interpreter is misrecognized

Problem persists without calling from topgrade

  • Yes
  • No

Did you run topgrade through Remote Execution

  • Yes
  • No

If yes, does the issue still occur when you run topgrade directlly in your
remote host

  • Yes
  • No

Configuration file (Optional)

Additional Details

  • Operation System/Version
    Fedora 41
    Poetry 1.8.3 installed with dnf

  • Installation
    From fedora copr

  • Topgrade version (topgrade -V)
    16.0.2

Verbose Output (topgrade -v)

❯ topgrade --only poetry -v
DEBUG Current system locale is en-IL
DEBUG Configuration at /home/tsvika/.config/topgrade.toml
DEBUG Loaded configuration: ConfigFile { include: Some(Include { paths: None }), misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: None, ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, tmux_session_mode: None, cleanup: None, notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: Some({}), commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None, poetry_force_self_update: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, greedy_auto_updates: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, bootc: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: Some(Containers { ignored_containers: None, runtime: None }), windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: Some(Yarn { use_sudo: None }), deno: Some(Deno { version: None }), vim: Some(Vim { force_plug_update: None }), firmware: Some(Firmware { upgrade: None }), vagrant: Some(Vagrant { directories: None, power_on: None, always_suspend: None }), flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: Some(Lensfun { use_sudo: None }), julia: Some(JuliaConfig { startup_file: None }) }
DEBUG Version: 16.0.2
DEBUG OS: x86_64-unknown-linux-gnu
DEBUG Args { inner: ["topgrade", "--only", "poetry", "-v"] }
DEBUG Binary path: Ok("/usr/bin/topgrade")
DEBUG self-update Feature Enabled: false
DEBUG Configuration: Config { opt: CommandLineArgs { edit_config: false, show_config_reference: false, run_in_tmux: false, cleanup: false, dry_run: false, no_retry: false, disable: [], only: [Poetry], custom_commands: [], env: [], verbose: true, keep_at_end: false, skip_notify: false, yes: None, disable_predefined_git_repos: false, config: None, remote_host_limit: None, show_skipped: false, log_filter: "warn", gen_completion: None, gen_manpage: false, no_self_update: false }, config_file: ConfigFile { include: Some(Include { paths: None }), misc: Some(Misc { pre_sudo: None, sudo_command: None, disable: None, ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, no_retry: None, run_in_tmux: None, tmux_session_mode: None, cleanup: None, notify_each_step: None, skip_notify: None, bashit_branch: None, only: None, no_self_update: None, log_filters: None }), pre_commands: Some({}), post_commands: Some({}), commands: Some({}), python: Some(Python { enable_pip_review: None, enable_pip_review_local: None, enable_pipupgrade: None, pipupgrade_arguments: None, poetry_force_self_update: None }), composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, greedy_latest: None, greedy_auto_updates: None, autoremove: None, fetch_head: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, garuda_update_arguments: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, nix_arguments: None, nix_env_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, suse_dup: None, rpm_ostree: None, bootc: None, emerge_sync_flags: None, emerge_update_flags: None, home_manager_arguments: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), containers: Some(Containers { ignored_containers: None, runtime: None }), windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, wsl_update_pre_release: None, wsl_update_use_web_download: None }), npm: Some(NPM { use_sudo: None }), yarn: Some(Yarn { use_sudo: None }), deno: Some(Deno { version: None }), vim: Some(Vim { force_plug_update: None }), firmware: Some(Firmware { upgrade: None }), vagrant: Some(Vagrant { directories: None, power_on: None, always_suspend: None }), flatpak: Some(Flatpak { use_sudo: None }), distrobox: Some(Distrobox { use_root: None, containers: None }), lensfun: Some(Lensfun { use_sudo: None }), julia: Some(JuliaConfig { startup_file: None }) }, allowed_steps: [Poetry] }
DEBUG Cannot find "pwsh"
DEBUG Cannot find "powershell"
DEBUG Path "/home/tsvika/.config/emacs" doesn't exist
DEBUG Path "/home/tsvika/.emacs.d" doesn't exist
DEBUG Cannot find "doas"
DEBUG Detected "/usr/bin/sudo" as "sudo"
DEBUG Step "Poetry"
DEBUG Detected "/usr/bin/poetry" as "poetry"
DEBUG poetry interpreter:  /usr/bin/python3 -sP
DEBUG Executing command ` /usr/bin/python3 -sP -c 'import sys; from os import path; print('\''Y'\'') if path.isfile(path.join(sys.prefix, '\''poetry_env'\'')) else print('\''N'\'')'`
DEBUG Step "Poetry" failed: 
   0: Failed to execute ` /usr/bin/python3 -sP -c 'import sys; from os import path; print('\''Y'\'') if path.isfile(path.join(sys.prefix, '\''poetry_env'\'')) else print('\''N'\'')'`
   1: No such file or directory (os error 2)

Location:
src/steps/generic.rs:1095
Poetry failed:
0: Failed to execute /usr/bin/python3 -sP -c 'import sys; from os import path; print('\''Y'\'') if path.isfile(path.join(sys.prefix, '\''poetry_env'\'')) else print('\''N'\'')'
1: No such file or directory (os error 2)

Location:
src/steps/generic.rs:1095
Retry? (y)es/(N)o/(s)hell/(q)uit⏎

@tsvikas tsvikas added the C-bug Something isn't working label Jan 24, 2025
@SteveLauC
Copy link
Member

Thanks for reporting this!

cc @AThePeanut4, looks like we didn't check if file path.join(sys.prefix, 'poetry_env') exists or not before passing it to path.is_file() in our check_official_install_script, mind taking a look at this?

https://github.com/topgrade-rs/topgrade/blame/9a6fe8eea911be0ff13a4e54b6742c63b40138df/src/steps/generic.rs#L1158-L1159

@AThePeanut4
Copy link
Contributor

AThePeanut4 commented Feb 2, 2025

@SteveLauC I believe the issue is with the python interpreter being misrecognized: it's using /usr/bin/python3 -sP which I believe will cause problems both because of the leading space and because of the -sP. os.path.isfile doesn't throw an exception if the path doesn't exist, it just returns False.

@tsvikas Would you mind sending your poetry wrapper script here? i.e. just copy the output of cat /usr/bin/poetry.

@AThePeanut4
Copy link
Contributor

I checked the rpm for poetry-1.8.3 and it does indeed have #! /usr/bin/python3 -sP as the shebang line in /usr/bin/poetry.

I've already made a fix that parses the shebang line to remove leading spaces and split out any arguments. I just need to test it on windows and then I'll send a PR through.

@AThePeanut4 AThePeanut4 linked a pull request Feb 3, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants