Skip to content

Commit 6ce1cc9

Browse files
committed
support customizing install directory with $DPATH
This introduces the $DPATH environment variable to override the user's home directory just for D tools. This is also intended to be used by DUB (dlang/dub#2281) when there is not the more explicit `$DUB_HOME` variable set on the system. This allows users who install their D compiler through the install.sh script to both have the compiler installations as well as the dub packages be stored elsewhere in the system than in their home folder. In case we have other tools that download their dependencies into the user's home directory, we should also make them support the same $DPATH environment variable.
1 parent 194c9c8 commit 6ce1cc9

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

changelog/dpath.dd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The `install.sh` script now respects the `$DPATH` environment variable
2+
3+
The `$DPATH` environment variable can be set on any system to make the install location of the install.sh script as well as other D related tools like DUB to store their cache files, dependencies, installed compilers, etc.
4+
5+
This way you can change where all the D tools are installed and keep a clean home folder.

script/install.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,21 @@ GET_PATH_AUTO_INSTALL=0
176176
GET_PATH_COMPILER=dc
177177
# Set a default install path depending on the POSIX/Windows environment.
178178
if posix_terminal; then
179-
ROOT=~/dlang
179+
if [ -z "$DPATH" ]; then
180+
ROOT=~/dlang
181+
else
182+
ROOT="$DPATH/dlang"
183+
fi
180184
else
181-
# Default to a ROOT that is outside the POSIX-like environment.
182-
if [ -z "$USERPROFILE" ]; then
183-
fatal '%USERPROFILE% should not be empty on Windows.';
185+
if [ -z "$DPATH" ]; then
186+
# Default to a ROOT that is outside the POSIX-like environment.
187+
if [ -z "$USERPROFILE" ]; then
188+
fatal '%USERPROFILE% should not be empty on Windows.';
189+
fi
190+
ROOT=$(posix_path "$USERPROFILE")/dlang
191+
else
192+
ROOT=$(posix_path "$DPATH")/dlang
184193
fi
185-
ROOT=$(posix_path "$USERPROFILE")/dlang
186194
fi
187195
TMP_ROOT=
188196
DUB_VERSION=

0 commit comments

Comments
 (0)