You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Lastly, we also consider it writable if we have passwordless sudo (since then we don't need to prompt/error due to lack of permissions)
239
+
sudo -n true2>/dev/null
235
240
}
236
241
237
242
# Resolve the install directory
@@ -248,18 +253,20 @@ resolveInstallDir() {
248
253
249
254
# Handle non-interactive scenarios where prompt or sudo are not possible
250
255
if [ "$NON_INTERACTIVE"="true" ];then
251
-
# If the install directory was explicitly set and requires sudo, we error
252
-
if [ -n"$INSTALL_DIR" ] && [ "$INSTALL_DIR_EXPLICIT"="true" ] &&! installDirIsWritable;then
253
-
printf"Install directory '%s' requires elevated permissions, which are not available in non-interactive mode.\n""$INSTALL_DIR"
254
-
exit 1
256
+
# Default to /usr/local/bin if not set.
257
+
if [ -z"$INSTALL_DIR" ];then
258
+
INSTALL_DIR="/usr/local/bin"
255
259
fi
256
260
257
-
# If the install directory is not set, or the previous installation path requires sudo, we default to installing in the current directory
258
-
if [ -z"$INSTALL_DIR" ];then
259
-
printf"Non-interactive shell detected; defaulting to install in current directory.\n"
260
-
INSTALL_DIR=$(pwd)
261
-
elif! installDirIsWritable;then
262
-
printf"Non-interactive shell detected; previous installation at '%s' requires elevated permissions; defaulting to install in current directory.\n""$INSTALL_DIR"
261
+
# Handle if the install directory is not writable and we can't prompt due to non-interactive mode.
262
+
if! installDirIsWritable;then
263
+
# Error if the install directory was set explicitly.
264
+
if [ "$INSTALL_DIR_EXPLICIT"="true" ];then
265
+
printf"Install directory '%s' requires elevated permissions, which are not available in non-interactive mode.\n""$INSTALL_DIR"
266
+
exit 1
267
+
fi
268
+
269
+
# Fall back to the current directory otherwise (which we assume is writable).
0 commit comments