|
58 | 58 | setupScript = '' |
59 | 59 | export HOME=$(mktemp -d) |
60 | 60 |
|
| 61 | + # On macOS, the nix build user's home is /var/empty which is read-only. |
| 62 | + # The JVM resolves user.home from getpwuid(), not $HOME, so tools that |
| 63 | + # use System.getProperty("user.home") try to write to /var/empty/Library. |
| 64 | + # JAVA_TOOL_OPTIONS overrides user.home for regular JVM processes. |
| 65 | + # GraalVM native images (e.g. scala-cli) ignore JAVA_TOOL_OPTIONS, so |
| 66 | + # we override every directory env var they check to avoid the fallback |
| 67 | + # to user.home + /Library/... entirely. |
| 68 | + export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -Duser.home=\"$HOME\"" |
| 69 | + export SCALA_CLI_HOME="$HOME/.scala-cli" |
| 70 | + export COURSIER_CACHE="$HOME/.cache/coursier" |
| 71 | + export COURSIER_ARCHIVE_CACHE="$HOME/.cache/coursier-arc" |
| 72 | + export COURSIER_BIN_DIR="$HOME/.local/bin/coursier" |
| 73 | + export COURSIER_CONFIG_DIR="$HOME/.config/coursier" |
| 74 | + export COURSIER_JVM_CACHE="$HOME/.cache/coursier-jvm" |
| 75 | +
|
61 | 76 | # Set up Coursier cache - sbt uses .cache/coursier/https/... |
62 | | - mkdir -p $HOME/.cache |
63 | | - cp -r ${coursierCache} $HOME/.cache/coursier |
64 | | - chmod -R u+w $HOME/.cache/coursier |
| 77 | + mkdir -p "$HOME/.cache" |
| 78 | + cp -r ${coursierCache} "$HOME/.cache/coursier" |
| 79 | + chmod -R u+w "$HOME/.cache/coursier" |
65 | 80 |
|
66 | 81 | # Configure sbt for offline mode |
67 | 82 | export COURSIER_MODE=offline |
68 | | - export COURSIER_CACHE=$HOME/.cache/coursier |
69 | 83 | export SBT_OPTS="-Dsbt.offline=true -Dsbt.boot.directory=$HOME/.sbt/boot ${extraSbtOpts}" |
70 | 84 | ''; |
71 | 85 |
|
|
0 commit comments