-vvv option).Setting the cache-dir location using either the environment variable POETRY_CACHE_DIR or with poetry config cache-dir /path/to/new/cache does not work. Poetry still uses the default location C:\Users\<user>\AppData\Local\pypoetry\Cache.
This will not work for me as there are size constraints on my user profile directory. Beacuse of this I need to relocate this directory to another drive.
I believe this to be cause by the fact that the environment/config settings are never read when determining the cache location.
poetry/utils/appdirs.py
def user_cache_dir(appname):
r"""
Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
Typical user cache directories are:
macOS: ~/Library/Caches/<AppName>
Unix: ~/.cache/<AppName> (XDG default)
Windows: C:\Users\<username>\AppData\Local\<AppName>\Cache
On Windows the only suggestion in the MSDN docs is that local settings go
in the `CSIDL_LOCAL_APPDATA` directory. This is identical to the
non-roaming app data dir (the default returned by `user_data_dir`). Apps
typically put cache data somewhere *under* the given dir here. Some
examples:
...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
...\Acme\SuperApp\Cache\1.0
OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
"""
if WINDOWS:
# Get the base path
path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
# Add our app name and Cache directory to it
path = os.path.join(path, appname, "Cache")
elif sys.platform == "darwin":
# Get the base path
path = expanduser("~/Library/Caches")
# Add our app name to it
path = os.path.join(path, appname)
else:
# Get the base path
path = os.getenv("XDG_CACHE_HOME", expanduser("~/.cache"))
# Add our app name to it
path = os.path.join(path, appname)
return path
Far from ideal, but as a workaround you can temporarily set/replace XDG_CACHE_HOME, eg:
XDG_CACHE_HOME=/path/to/another/drive/cache poetry add black
(tested on 1.0.9)
Hello,
I tested it with the latest preview release without any problems. Is someone else able to reproduce the issue?
fin swimmer
I've found something strange behavior on this topic.
Using poetry version 1.1.2, on Windows, I wanted run some script runnning with System privileges, I want to set cache-dir set other than Windows system directory.
When testing with normal user account,
C:\Users\ispark_skcc\AppData\Local\pypoetry\ used
$ poetry shell
$ poetry add semver
...
$ gtree -dL 2 C:\Users\ispark_skcc\appdata\local\pypoetry\Cache
C:\Users\ispark_skcc\appdata\local\pypoetry\Cache
|-- artifacts
| `-- d1
`-- cache
`-- repositories
$ gtree -dL 3 C:\Users\ispark_skcc\appdata\local\pypoetry\Cache
C:\Users\ispark_skcc\appdata\local\pypoetry\Cache
`-- cache
`-- repositories
`-- pypi
Most helpful comment
Far from ideal, but as a workaround you can temporarily set/replace
XDG_CACHE_HOME, eg:(tested on 1.0.9)