actionless / pikaur

AUR helper with minimal dependencies. Review PKGBUILDs all in once, next build them all without user interaction.
GNU General Public License v3.0
860 stars 87 forks source link

Correctly source paths #806

Closed samuel-jimenez closed 3 months ago

samuel-jimenez commented 3 months ago

Prefer environment variables over config; sync config based on first-run environment (Fixes #801).

actionless commented 3 months ago

@Baerbeisser could you test pls?

Baerbeisser commented 3 months ago

Ah, sorry, yes.

Mh, i get

  File "/home/dani/pikaur/pikaur/main.py", line 431, in main
    create_dirs()
  File "/home/dani/pikaur/pikaur/main.py", line 381, in create_dirs
    mkdir(AurReposCachePath()())
  File "/home/dani/pikaur/pikaur/core.py", line 389, in mkdir
    path.mkdir(parents=True)
  File "/usr/lib/python3.12/pathlib.py", line 1315, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/usr/lib/python3.12/pathlib.py", line 1315, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/usr/lib/python3.12/pathlib.py", line 1315, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  [Previous line repeated 1 more time]
  File "/usr/lib/python3.12/pathlib.py", line 1311, in mkdir
    os.mkdir(self, mode)

PermissionError: [Errno 13] Permission denied: '/home/dani.'

still new pikaur.conf with wrong cachepath + datapath generated.

pikaur.conf.gz

(tf, Github doesn't support conf/cfg files??)

samuel-jimenez commented 3 months ago

are you using $HOME/.local or $HOME./local?

Baerbeisser commented 3 months ago

Oops. 😳 Works now.

But still same with pikaur.conf

To clarify: my problem is that initial pikaur.conf gets created with wrong cachepath + datapath values (and then used) even though XDG variables are set. I think i made that too less clear initiallly.

samuel-jimenez commented 3 months ago

Does this still happen if you delete the entries from your config? They should only be created if they don't exist yet. They will be overridden if you have the variables set, but not overwritten.

Baerbeisser commented 3 months ago

No, they only get recreated exactly the same. ~/.cache and ~/.local/share

I know that those are intended by XDG to be used if no variable is set, so i guess that check fails?

$ export XDG_CACHE_HOME=$HOME/.local/tmp
$ export XDG_DATA_HOME=$HOME/.local/data
$ ./pikaur.py -Sy
:: Paketdatenbanken werden synchronisiert …
...

works for you?

samuel-jimenez commented 3 months ago

Is pikaur using the variables at all? Does using --pikaur-config change anything? This branch has increased output: https://github.com/samuel-jimenez/pikaur/tree/debug-xdg Can you post those logs?

Baerbeisser commented 3 months ago

pikaur.log

Looks like it does get the variables but then

_CachePathDefault
--xdg-cache-home:  /home/dani/.local/tmp
XDG_CACHE_HOME:  None

_DataPathDefault
--xdg-data-home:  /home/dani/.local/data
XDG_DATA_HOME:  None

_UserCacheRoot
--xdg-cache-home:  /home/dani/.local/tmp
XDG_CACHE_HOME:  None
config:  /home/dani/.cache

DataRoot
--xdg-data-home:  /home/dani/.local/data
XDG_DATA_HOME:  None
config:  /home/dani/.local/share
samuel-jimenez commented 3 months ago

Thanks, and if you use --pikaur-config=/home/dani/.config/pikaur0.conf?

Baerbeisser commented 3 months ago

Now it did. The debug-xdg one, that is.

cachepath = /home/dani/.local/tmp
datapath = /home/dani/.local/data

pikaur.log

pikaur0.conf.log

samuel-jimenez commented 3 months ago

The branches only differ by the amount of output they produce.

This is now working as intended by finding the default paths if and only if they do not exist. If you want them to be regenerated, you can comment them out in your original config. e.g., # cachepath = ..

Baerbeisser commented 3 months ago

My bad, i didn't update the changes of this branch. Though now i only get

:: error: Read damn arch-wiki before borking your computer

while the xdg branch works. pikaur.conf exists, with cachepath and datapath removed.

yay happily updates away, so i don't thinks there's anything borked.

samuel-jimenez commented 3 months ago

My bad, i didn't update the changes of this branch. Though now i only get

:: error: Read damn arch-wiki before borking your computer

I don't know that message, but I don't think it's from pikaur.

while the xdg branch works. pikaur.conf exists, with cachepath and datapath removed.

yay happily updates away, so i don't thinks there's anything borked.

If your config is not being updated, perhaps pikaur is using a different config? Using --pikaur-debug may provide more info.

How are you changing branches? I wonder if it's a failed merge. Try git switch and git reset --hard to ensure your repo state is consistent.

Baerbeisser commented 3 months ago

I don't know that message, but I don't think it's from pikaur.

It's literally

$ LC_ALL=C ./pikaur.py -Sy
:: error: Read damn arch-wiki before borking your computer

pikaur.conf exists, with cachepath and datapath removed.

Sorry for the misunderstanding, what i meant is, the error isn't because of a missing pikaur.conf. And i removed those two lines, so pikaur should update them again. They do get re-created while pikaur throws the error. But again

cachepath = /home/dani/.cache
datapath = /home/dani/.local/share

I just use the "Download as zip" function, delete the content of the folder and extract there.

samuel-jimenez commented 3 months ago

I don't know that message, but I don't think it's from pikaur.

It's literally

$ LC_ALL=C ./pikaur.py -Sy
:: error: Read damn arch-wiki before borking your computer

That triggers it for you, but the error is not in pikaur. If you grep -r borking . in the pikaur directory, you will get no results. If I had to guess, I would look at GNOME.

pikaur.conf exists, with cachepath and datapath removed.

Sorry for the misunderstanding, what i meant is, the error isn't because of a missing pikaur.conf. And i removed those two lines, so pikaur should update them again. They do get re-created while pikaur throws the error. But again

cachepath = /home/dani/.cache
datapath = /home/dani/.local/share

I just use the "Download as zip" function, delete the content of the folder and extract there.

If you follow that same procedure with the debug-xdg branch, what is the result?

Baerbeisser commented 3 months ago

I use XFCE and i do have custom login scripts but grep -Irn borking shows nothing in /etc and ~/.config. And it's in the same shell as before the update.

But i do find

pikaur/main.py:450:                "Read damn arch-wiki before borking your computer",

You searched borked instead of borking? 😉

debug-xdg replaces cachepath and datapath correctly with XDG_* vars content.

edit: i updated both again and debug-xdg really does work while main prints that error and uses default ~/.cache and ~/.local/share.

samuel-jimenez commented 3 months ago

:facepalm: Well, that explains it! It came in on 0b94fd0, and I haven't pulled that one yet.

It won't be on main until this gets merged. You can test with this branch: https://github.com/samuel-jimenez/pikaur/tree/prefer-env-vars

Baerbeisser commented 3 months ago

Yep, this branch works as it should. datapath and cachepath are correct.

About the error, this part in main.py seems new, will that check for base-devel remain?
If so, it will somewhat break support for doas, since sudo is part of base-devel. And if you use doas you likely will remove sudo and removing sudo removes base-devel. To which a work-around is to install the individual tools separately but then no base-devel group will be detected.

samuel-jimenez commented 3 months ago

I am not certain, as I did not author those changes. If you will kindly open a new issue we can get that resolved.

actionless commented 3 months ago

any update on this one?

i'm planning to make 1.22 release soon, and i need this feature either fixed or unmerged

samuel-jimenez commented 3 months ago

It has been fixed and is ready to merge

actionless commented 3 months ago

thanks a lot!

Baerbeisser commented 3 months ago

Though the check for base-devel with warning about borking your computer still remains if you used the workarounds to install doas.

actionless commented 3 months ago

but it's not related to this issue, right?

Baerbeisser commented 3 months ago

My bad, sorry.

actionless commented 3 months ago

@Baerbeisser no worries, feel free to elaborate further on that in that ticket which you created 👍