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

pikaur is ignoring $EDITOR #741

Closed
gheritarish opened this issue Jul 31, 2023 · 15 comments
Closed

pikaur is ignoring $EDITOR #741

gheritarish opened this issue Jul 31, 2023 · 15 comments

Comments

@gheritarish
Copy link

gheritarish commented Jul 31, 2023

pikaur -Syu

...

:: Repository package will be installed:
 lib32-libgudev                        237-2                -> 238-1

:: Proceed with installation? [Y/n]
:: [v]iew package details   [m]anually select packages
>> m
Description:

pikaur is ignoring my editor when I want to edit the list of packages to update (as shown above), or when I want to edit a PKGBUILD file. nano is opened while my editor is set to nvim (and the root editor to vim).

I don't know why nano is picked over nvim / vim, though…

Attached log:

You'll find:

  1. the debug mode for the update, showing nano is opened when editing what to upgrade
  2. the result of pikaur --version
  3. the result of echo $EDITOR
pikaur -Syu --verbose --pikaur-debug	

: debug: main_1000: Setting stdout to utf-8...
:: debug: main_1000: already set - nothing to do
:: debug: main_1000: Setting stderr to utf-8...
:: debug: main_1000: already set - nothing to do
:: debug: main_1000: Pikaur operation found for args ['/usr/bin/pikaur', '-Syu', '--verbose', '--pikaur-debug']: cli_install_packages
=> sudo --preserve-env=EDITOR -- /usr/bin/pikaur -Syu --verbose --pikaur-debug --pikaur-config=/home/telmar/.config/pikaur.conf --user-id=1000 --home-dir=/home/telmar --xdg-config-home=/home/telmar/.config
:: debug: main_0: Setting stdout to utf-8...
:: debug: main_0: already set - nothing to do
:: debug: main_0: Setting stderr to utf-8...
:: debug: main_0: already set - nothing to do
:: debug: main_0: Pikaur operation found for args ['/usr/bin/pikaur', '-Syu', '--verbose', '--pikaur-debug', '--pikaur-config=/home/telmar/.config/pikaur.conf', '--user-id=1000', '--home-dir=/home/telmar', '--xdg-config-home=/home/telmar/.config']: cli_install_packages
:: debug: news: init
:: debug: news: fetch_latest
=> GET https://www.archlinux.org/feeds/news/
=> pacman --color=always --sync --refresh
:: Synchronising package databases...
 endeavouros is up to date
 core is up to date
 extra is up to date
 multilib is up to date
:: debug: pacman: Discarding repo cache...

:: Starting full AUR upgrade...
:: debug: install_info_fetcher:
Gonna fetch install info for:
    install_package_names=[]
    not_found_repo_pkgs_names=[]
    pkgbuilds_packagelists={}
    manually_excluded_packages_names=[]

Reading repository package databases...
Reading local package database...
:: debug: install_info_fetcher: Gonna get repo pkgs install info...
:: debug: pacman: Gonna get sysupgrade info...
=> pacman --color=always --sync --sysupgrade --print-format %r/%n
:: debug: install_info_fetcher: gonna get AUR pkgs install info for:
    aur_packages_versionmatchers=[]
    self.aur_updates_install_info=[]
    aur_packages_names_to_versions={}
:: debug: install_info_fetcher: found AUR pkgs:
    aur_pkg_list=[]
not found AUR pkgs:
    not_found_aur_pkgs=[]

:: debug: prompt: Gonna get input from user...
:: debug: FileLock: Acquiring /tmp/pikaur_prompt_786188.lock...
:: debug: FileLock: Acquired /tmp/pikaur_prompt_786188.lock
:: debug: prompt_nolock: Restoring TTY...
:: debug: prompt_nolock: Using standard input reader...
:: Proceed with installation? [Y/n]
:: [v]iew package details   [m]anually select packages
>> m
:: debug: FileLock: Releasing /tmp/pikaur_prompt_786188.lock
:: debug: FileLock: Released /tmp/pikaur_prompt_786188.lock
:: debug: prompt: Got answer: 'm'

=> sudo --user=#1000 --preserve-env=EDITOR -- nano /tmp/tmpchvl6rkm
:: debug: install_info_fetcher:
Gonna fetch install info for:
    install_package_names=[]
    not_found_repo_pkgs_names=[]
    pkgbuilds_packagelists={}
    manually_excluded_packages_names=[]

---

❯ pikaur --version

      /:}               _
     /--1             / :}
    /   |           / `-/
   |  ,  --------  /   /     Pikaur v1.18.1
   |'                 Y      (C) 2018-2023 Pikaur development team
  /                   l      Licensed under GPLv3
  l  /       \        l
  j  ●   .   ●        l      Pacman v6.0.2 - libalpm v13.0.2
 { )  ._,.__,   , -.  {      pyalpm v0.10.6
  Y    \  _/     ._/   \

---

❯ echo $EDITOR
nvim

(I dropped a few lines, but they weren't relevant imo)

Thanks!

Update: I didn't have the problem with pikaur 1.17-1, which was the installed version until yesterday on my machine, according to pacman logs.

@actionless
Copy link
Owner

what the output of sudo --preserve-env=EDITOR bash -c 'echo $EDITOR' ?

also install latest pikaur-git and upload the log again please

@gheritarish
Copy link
Author

gheritarish commented Aug 2, 2023

Well, there we have it:

❯ sudo --preserve-env=EDITOR bash -c 'echo $EDITOR'
nano

(as a note: without specifying the EDITOR in preserve-env, the result is nvim, as expected)

And for the logs:

:: debug: install_info_fetcher: got AUR pkgs install info: []
=> pacman --color=always --query --upgrades --quiet
=> pacman --color=always --sync lib32-libgudev --print-format %r/%n
:: debug: install_cli: self.install_info.all_install_info_containers=([<RepoInstallInfo "lib32-libgudev" 237-2 -> 238-1>], [], [], [], [], [], [], [])
:: debug: news: print
:: debug: news: loading date from /home/telmar/.cache/pikaur/last_seen_news.dat
:: debug: news: data: Sun, 18 Jun 2023 09:14:37 +0000, parsed: 2023-06-18 09:14:37+00:00
:: debug: news: Arch News Date: 2023-06-18 09:14:37+00:00, Last-seen date: 2023-06-18 09:14:37+00:00

:: Repository package will be installed:
 lib32-libgudev                        237-2                -> 238-1

:: debug: prompt: Gonna get input from user...
:: debug: FileLock: Acquiring /tmp/pikaur_prompt_502584.lock...
:: debug: FileLock: Acquired /tmp/pikaur_prompt_502584.lock
:: debug: prompt_nolock: Restoring TTY...
:: debug: prompt_nolock: Using standard input reader...
:: Proceed with installation? [Y/n]
:: [v]iew package details   [m]anually select packages
>> m
:: debug: FileLock: Releasing /tmp/pikaur_prompt_502584.lock
:: debug: FileLock: Released /tmp/pikaur_prompt_502584.lock
:: debug: prompt: Got answer: 'm'

:: debug: prompt: Found editor: nano
=> sudo --user=#1000 --preserve-env=EDITOR -- nano /tmp/tmp5m5azstn

So that explains the "bug". Thanks for the help!

Update: I fixed it by specifying to preserve the EDITOR in the sudoers file, but since I didn't needed that before, I'll let you choose if you want to chose the issue or not.

@actionless
Copy link
Owner

weird - did you previously altered your sudoers file?

i have default config file from arch linux and it being preserved, so in the first case i'm seeing output of EDITOR set in the current user, not in root

@gheritarish
Copy link
Author

No, I never edited it before.

I use endeavour, not pure arch, but it should be globally the same file I think

@actionless
Copy link
Owner

that's weird, but since i can't reproduce the problem in arch - i'm closing this one

@actionless actionless closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2023
@jonathan-strange
Copy link

jonathan-strange commented Aug 30, 2023

Same issue here, using Manjaro.

> echo $EDITOR
vim                                                                                                                                                                              
> sudo --preserve-env=EDITOR bash -c 'echo $EDITOR' 
usr/bin/nano

My fix is add the following to /etc/sudoers (remember to use visudo)

Defaults env_keep += "EDITOR VISUAL"

@notEvil
Copy link

notEvil commented Sep 4, 2023

For me, the culprit was /etc/environment where Cnchi (legacy installer of Antergos) added EDITOR=/usr/bin/nano. And since pikaur is using a non-interactive shell, that was used instead of user (interactive) configuration like ~/.bashrc.

@actionless
Copy link
Owner

i wonder, if it would be better then to spawn commands with some different sudo flags?

@notEvil
Copy link

notEvil commented Sep 4, 2023

Running the editor as user would be ideal imo. With sudo -E you get the same experience as if you were the user, but with potential for file ownership issues (e.g. Neovim; new files are owned by root and typically not writable by the user after that)

@actionless
Copy link
Owner

actionless commented Sep 6, 2023

no, preserving all env variables (-E) wouldn't work in this case:

your user
      |
      v
sudo pikaur
      |-----------|
      v           v
pacman    sudo -u your_user EDITOR_CMD

because in that case all your env variables would end up in pacman, while it should be running with root's env vars

@actionless
Copy link
Owner

actionless commented Sep 6, 2023

Running the editor as user would be ideal imo

and this is a good point - i've just realized that during build and during PKGBUILD review editor command is not changing the user properly, i'll fix this

@notEvil
Copy link

notEvil commented Sep 6, 2023

I see. Maybe sudo -i then? It doesn't preserve the original environment though.

@actionless
Copy link
Owner

please don't do any suggestions, if you don't know for sure

@notEvil
Copy link

notEvil commented Sep 6, 2023

I read the man page and from my experience it looks like a reasonable solution. But I haven't read the source code of pikaur from start to finish nor did I try every possible user configuration to make sure this is definitely the way to go. Maybe I will, but probably not.

My first suggestion was under the assumption that pikaur is run as user and elevates privileges only for pacman, which is not unreasonable to assume.

@actionless
Copy link
Owner

My first suggestion was under the assumption that pikaur is run as user and elevates privileges only for pacman, which is not unreasonable to assume.

that's described in readme, reading is usually more effective than asuming ;)

actionless added a commit that referenced this issue Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants