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

Cache path resolution not optimal: setting cachepath should have priority on the default XDG_CACHE_HOME #843

Open Oxalin opened 1 day ago

Oxalin commented 1 day ago

Current situation

According to the README: "CachePath (default: ~/.cache) Path to package cache location. Will be overridden by --xdg-cache-home argument or environment variable XDG_CACHE_HOME, if set."

The actual cache path resolution order is then as follow:

  1. Command line options (--xdg-cache-home)
  2. Environment variables (XDG_CACHE_HOME)
  3. Config setting (cachepath = ..)

This leads to a situation where CachePath is mostly never used, unless XDG_CACHE_HOME is unset.

Proposed change

  1. Command line options (--xdg-cache-home)
  2. Config setting (cachepath = ..)
  3. Environment variables (XDG_CACHE_HOME)

This proposition invert the priority given to XDG_CACHE_HOME with the one given to cachepath.

Reasoning

Under Linux, the XDG_CACHE_HOME is a global variable that is used to set a default base cache path for any and all applications requiring a default path. Since it is set by default, it should be used as a last resort if no other option, either by a config file or a command line option, is set. As it is right now, any value given to cachepath in the config file is never used unless XDG_CACHE_HOME is unset.

Specifying a variable in a config file should be seen as a way to divert from the default XDG_CACHE_HOME value for a given application. Thus, any CachePath value set in the config file should be used over XDG_CACHE_HOME.

Lastly, using the command line option should be treated as a special case where the user wants to use a different path in a specific situation or context (a specific package may need a lot of space, where it will exceed the available space left in a home partition. For example, the cosmic-session package is used to build many sub-packages and the resulting build folder takes).

Using this reasoning, pikaur should:

actionless commented 1 day ago

CC @samuel-jimenez