Skip to content

Commit

Permalink
Align home-dir with original scripts
Browse files Browse the repository at this point in the history
The original bash script uses the `HOME` environment variable[1] to determine the user's home
directory while we were using thee `user.home` JVM property on non-windows platforms. This turns out
to not be equivalent (see e.g. JDK-8280357[2] for a recent issue caused by this). So instead, we now
also use the environment variable.

As it turns out, the original Powershell script also first checks the `HOME` environment variable[3]
before falling back to `USERPROFILE` (which is what we were using so far), so we also align that to
ensure equivalent behavior. This also means we can drop the "workaround" comment here since it no
longer is one.

Closes borkdude#114.

[1]  https://github.com/clojure/brew-install/blob/b03428b1b31a8d60573a284d6971fbd3db7b748d/src/main/resources/clojure/install/clojure#L280
[2]  https://bugs.openjdk.org/browse/JDK-8280357
[3]  https://github.com/clojure/brew-install/blob/dabb82bd011b0510006dd88464f350052adb69b5/src/main/resources/clojure/install/ClojureTools.psm1#L254-L258
  • Loading branch information
DerGuteMoritz committed Oct 12, 2023
1 parent cc9ddf4 commit 97138ed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ DEPS_CLJ_TOOLS_VERSION=1.11.1.1165 bb clojure

[deps.clj](https://github.com/borkdude/deps.clj): a faithful port of the clojure CLI bash script to Clojure

## Unreleased

- [#114](https://github.com/borkdude/deps.clj/issues/114): Align with original scripts on how to determine home directory

## 1.11.1.1413

- Catch up with CLI `1.11.1.1413`
Expand Down
6 changes: 3 additions & 3 deletions deps.bat
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ For more info, see:

(defn- home-dir []
(if windows?
;; workaround for https://github.com/oracle/graal/issues/1630
(*getenv-fn* "userprofile")
(System/getProperty "user.home")))
(or (*getenv-fn* "home")
(*getenv-fn* "userprofile"))
(*getenv-fn* "home")))

(def ^:private java-exe (if windows? "java.exe" "java"))

Expand Down
6 changes: 3 additions & 3 deletions deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ For more info, see:

(defn- home-dir []
(if windows?
;; workaround for https://github.com/oracle/graal/issues/1630
(*getenv-fn* "userprofile")
(System/getProperty "user.home")))
(or (*getenv-fn* "home")
(*getenv-fn* "userprofile"))
(*getenv-fn* "home")))

(def ^:private java-exe (if windows? "java.exe" "java"))

Expand Down
6 changes: 3 additions & 3 deletions src/borkdude/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ For more info, see:

(defn- home-dir []
(if windows?
;; workaround for https://github.com/oracle/graal/issues/1630
(*getenv-fn* "userprofile")
(System/getProperty "user.home")))
(or (*getenv-fn* "HOME")
(*getenv-fn* "USERPROFILE"))
(*getenv-fn* "HOME")))

(def ^:private java-exe (if windows? "java.exe" "java"))

Expand Down

0 comments on commit 97138ed

Please sign in to comment.