Skip to content

Commit 1c1ef92

Browse files
committed
lein.sh: honor XDG_CACHE_HOME
Closes #3572
1 parent 20d8542 commit 1c1ef92

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html): display Java class/method/field info when available.
1212
- This info is available when [enrich-classpath](https://docs.cider.mx/cider/config/basic_config.html#use-enrich-classpath) is active.
1313
- `cider-popup-buffer-display`: honor `special-display-buffer-names` if customized for a given CIDER buffer name (e.g. `*cider-inspect*`), avoiding the double-rendering of the given buffer.
14+
- [#3572](https://github.com/clojure-emacs/cider/issues/3572): `lein.sh`: honor `XDG_CACHE_HOME`.
1415
- Bump the injected `cider-nrepl` to [0.43.0](https://github.com/clojure-emacs/cider-nrepl/blob/v0.43.0/CHANGELOG.md#0430-2023-11-04).
1516
- Improves performance for exception handling and other use cases.
1617

lein.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ shift
1313
output=$(2>&1 "$lein" "$@")
1414
cmd=$(grep "\s-cp\s"<<< "$output")
1515

16+
function cache_root() {
17+
local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}"
18+
cache_dir="${cache_dir/#\~/$HOME}"
19+
mkdir -p "$cache_dir" 2>/dev/null
20+
if [[ -w "$cache_dir" ]]; then
21+
echo "${cache_dir%/}"
22+
else
23+
return 1
24+
fi
25+
}
26+
1627
if grep --silent "\s-cp\s"<<< "$cmd"; then
1728
eval "$cmd"
1829
else
1930
# Print errors:
20-
mkdir -p ~/.emacs.d
21-
echo "$output" >> ~/.emacs.d/cider-error.log
31+
if cache_dir=$(cache_root); then
32+
logfile="$cache_dir"/cider-enrich-classpath-error.log
33+
echo "$output" >> "$logfile"
34+
echo "Could not activate enrich-classpath. Error report available at $logfile"
35+
fi
2236
no_enrich=()
2337
for arg in "$@"; do
2438
if [ "$arg" == "cider.enrich-classpath.plugin-v2/middleware" ]; then

0 commit comments

Comments
 (0)