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
In the install.sh file the following code is currently used to deal with shells:
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bash_profile" ;;
esac
The default case sets the shell_profile variable to ".bash_profile" without checking if this is a linux distribution.
I personally checked out the Linux distribution I use, which is Pop!_OS by System76, and it only ever sources the .bashrc file when I open a bash terminal. This is true even if I logout and in. This distribution is an Ubuntu-based distribution and most other Linux distributions only ever source ".bashrc" since they treat terminals run on the fly as non-login shells as opposed to Mac that treats these as login shells.
Simple Solution
To fix this issue the above code can be extended as follows to accommodate for bash on most Linux distributions:
Add the line of DENO_OS="linux" in the default case of the switch statement below:
if [ "$OS" = "Windows_NT" ]; then
target="x86_64-pc-windows-msvc"
else
case $(uname -s) in
Darwin) target="x86_64-apple-darwin" ;;
*)
target="x86_64-unknown-linux-gnu"
DENO_OS="linux" <-------[modified line]
;;
esac
fi
Next, prepend the default case of the switch statement below with [ "$DENO_OS" = "linux" ] && shell_profile=".bashrc"
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) [ "$DENO_OS" = "linux" ] && shell_profile=".bashrc" || shell_profile=".bash_profile" ;; <-------[modified line]
esac
NOTE: It is important for the "$DENO_OS" part to be encapsulated in quotes, otherwise it won't work on Mac due to DENO_OS not being defined in that case leaving no left parameter for the binary operator of = to work with.
Advanced Solution
An even better solution can be found by looking at the install script for the n Node version manager that uses the
following code:
# SYNOPSIS
# getShellInitFile
# DESCRIPTION
# Returns the full path of the initalization file of the shell identified
# via (environment variable) $SHELL, the user's default shell.
# If $SHELL refers to an *unsupported* shell, the empty string is returned.
getShellInitFile() {
local initFile=''
# IMPORTANT:
# This STATEMENT MUST BE KEPT IN SYNC with cleanUpShellInitFile() in n-uninstall.
case "$(basename -- "$SHELL")" in
'bash')
# !! Sadly, bash ONLY reads ~/.bash_profile in LOGIN shells, and on macOS (Darwin) ALL shells are login shells, so on macOS we must target ~/.bash_profile.
[[ $(uname) == 'Darwin' ]] && initFile=~/.bash_profile || initFile=~/.bashrc
;;
'ksh')
initFile=~/.kshrc
;;
'zsh')
initFile=${ZDOTDIR:-~}/.zshrc
;;
'fish')
initFile=${XDG_CONFIG_HOME:-~/.config}/fish/config.fish
;;
'pwsh') # PowerShell
initFile=${XDG_CONFIG_HOME:-~/.config}/powershell/Microsoft.PowerShell_profile.ps1
;;
esac
printf %s "$initFile"
}
Issue Overview
In the
install.sh
file the following code is currently used to deal with shells:The default case sets the
shell_profile
variable to ".bash_profile" without checking if this is a linux distribution.I personally checked out the Linux distribution I use, which is Pop!_OS by System76, and it only ever sources the
.bashrc
file when I open a bash terminal. This is true even if I logout and in. This distribution is an Ubuntu-based distribution and most other Linux distributions only ever source ".bashrc" since they treat terminals run on the fly as non-login shells as opposed to Mac that treats these as login shells.Simple Solution
To fix this issue the above code can be extended as follows to accommodate for bash on most Linux distributions:
Add the line of
DENO_OS="linux"
in the default case of the switch statement below:Next, prepend the default case of the switch statement below with
[ "$DENO_OS" = "linux" ] && shell_profile=".bashrc"
NOTE: It is important for the
"$DENO_OS"
part to be encapsulated in quotes, otherwise it won't work on Mac due toDENO_OS
not being defined in that case leaving no left parameter for the binary operator of=
to work with.Advanced Solution
An even better solution can be found by looking at the install script for the
n
Node version manager that uses thefollowing code:
Link: https://github.com/mklement0/n-install/blob/master/bin/n-install
Line: 262
The above solution caters for quite a few different shells which is a plus.
The text was updated successfully, but these errors were encountered: