mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
Use os.UserCacheDir as first fallback if cacheDir is not set
We will now try 1. cacheDir (or, commonly set in environment as `HUGO_CACHEDIR`) 2. if on Netlify we use `/opt/build/cache/hugo_cache/` 3. os.UserCacheDir 4. A temp dir Storing the cache, especially the module cache, in a temporary idea has had lots of hard to debug issues, especially on MacOS, which this commit tries to fix. This should also make it easier to locate the Hugo cache: >UserCacheDir returns the default root directory to use for user-specific cached data. Users should create their own application-specific subdirectory within this one and use that. > >On Unix systems, it returns $XDG_CACHE_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.cache. On Darwin, it returns $HOME/Library/Caches. On Windows, it returns %LocalAppData%. On Plan 9, it returns $home/lib/cache. > >If the location cannot be determined (for example, $HOME is not defined), then it will return an error. Fixes #11286 Fixes #11291
This commit is contained in:
parent
4d7af757c9
commit
b3f10556f0
4 changed files with 54 additions and 5 deletions
18
testscripts/commands/config__cachedir.txt
Normal file
18
testscripts/commands/config__cachedir.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
[windows] skip
|
||||
|
||||
env HUGO_CACHEDIR=
|
||||
hugo config
|
||||
|
||||
[darwin] stdout 'home/Library/Caches/hugo_cache'
|
||||
[linux] stdout 'xdgcachehome/hugo_cache'
|
||||
|
||||
# Repeat it to make sure it handles an existing hugo_cache dir.
|
||||
hugo config
|
||||
|
||||
[darwin] stdout 'home/Library/Caches/hugo_cache'
|
||||
[linux] stdout 'xdgcachehome/hugo_cache'
|
||||
|
||||
-- hugo.toml --
|
||||
baseURL="https://example.com/"
|
||||
title="My New Hugo Site"
|
Loading…
Add table
Add a link
Reference in a new issue