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

Correctly source paths #806

Merged
merged 2 commits into from
Jun 15, 2024
Merged

Conversation

samuel-jimenez
Copy link
Contributor

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

@actionless
Copy link
Owner

@Baerbeisser could you test pls?

@Baerbeisser
Copy link

Baerbeisser commented Jun 5, 2024

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
Copy link
Contributor Author

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

@Baerbeisser
Copy link

Baerbeisser commented Jun 5, 2024

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
Copy link
Contributor Author

samuel-jimenez commented Jun 5, 2024

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
Copy link

Baerbeisser commented Jun 5, 2024

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
Copy link
Contributor Author

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
Copy link

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
Copy link
Contributor Author

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

@Baerbeisser
Copy link

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
Copy link
Contributor Author

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
Copy link

Baerbeisser commented Jun 7, 2024

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
Copy link
Contributor Author

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
Copy link

Baerbeisser commented Jun 7, 2024

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
Copy link
Contributor Author

samuel-jimenez commented Jun 7, 2024

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
Copy link

Baerbeisser commented Jun 7, 2024

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
Copy link
Contributor Author

🤦 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
Copy link

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

It has been fixed and is ready to merge

@actionless
Copy link
Owner

thanks a lot!

@actionless actionless merged commit a3a476c into actionless:master Jun 15, 2024
2 checks passed
@Baerbeisser
Copy link

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

@actionless
Copy link
Owner

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

@Baerbeisser
Copy link

My bad, sorry.

@actionless
Copy link
Owner

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

@xPMo xPMo mentioned this pull request Jun 20, 2024
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

Successfully merging this pull request may close these issues.

XDG variables / config-settings confusion
3 participants