Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ensure correct nodejs version is installed #3691

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions scripts/install-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ PLUGIN_PATH=$(relpath "${ROOT_PATH}/plugins")
HALFSTACK_VOLUME_PATH=$(relpath "${ROOT_PATH}/volumes")
PANTS_VERSION=$($bpython scripts/tomltool.py -f pants.toml get 'GLOBAL.pants_version')
PYTHON_VERSION=$($bpython scripts/tomltool.py -f pants.toml get 'python.interpreter_constraints[0]' | awk -F '==' '{print $2}')
NODE_VERSION=$(curl -sL https://raw.githubusercontent.com/lablup/backend.ai-webui/main/.nvmrc)

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

SHOW_GUIDE=0
Expand Down Expand Up @@ -466,10 +468,10 @@ install_node() {
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
fi

node_version=$(curl -sL https://raw.githubusercontent.com/lablup/backend.ai-webui/main/.nvmrc)
show_info "Installing Node.js v${node_version} via NVM..."
nvm install $node_version
nvm use node

show_info "Installing Node.js v${NODE_VERSION} via NVM..."
nvm install $NODE_VERSION
nvm use $NODE_VERSION
}

set_brew_python_build_flags() {
Expand Down Expand Up @@ -593,7 +595,7 @@ bootstrap_pants() {
}

install_editable_webui() {
if ! command -v node &> /dev/null; then
if ! command -v node &> /dev/null || [ "$(node -v | awk -F. '{print $1}' | sed 's/v//')" != "$NODE_VERSION" ]; then
install_node
fi
if ! command -v pnpm &> /dev/null; then
Expand Down Expand Up @@ -718,31 +720,32 @@ wait_for_docker() {
done
}

append_to_profiles() {
script_content="$1"
PROFILE_FILES=("zshrc" "bashrc" "profile" "bash_profile" "config/fish/config.fish")

for PROFILE_FILE in "${PROFILE_FILES[@]}"; do
FULL_PATH="${HOME}/.${PROFILE_FILE}"

if [ -e "$FULL_PATH" ] && ! grep -qF "$script_content" "$FULL_PATH"; then
echo "$script_content" >>"$FULL_PATH"
fi
done
}

setup_environment() {
wait_for_docker
# Install pyenv
if ! type "pyenv" >/dev/null 2>&1; then
if [ -d "$HOME/.pyenv" ]; then
eval "$pyenv_init_script"
pyenv --version
fi
if ! type "pyenv" >/dev/null 2>&1 && [ ! -d "$HOME/.pyenv" ]; then
show_info "Installing pyenv..."
set -e
curl https://pyenv.run | sh
for PROFILE_FILE in "zshrc" "bashrc" "profile" "bash_profile"
do
if [ -e "${HOME}/.${PROFILE_FILE}" ]
then
echo "$pyenv_init_script" >> "${HOME}/.${PROFILE_FILE}"
fi
done
set +e
eval "$pyenv_init_script"
pyenv --version
_INSTALLED_PYENV=1
else
eval "$pyenv_init_script"
fi
append_to_profiles "$pyenv_init_script"
eval "$pyenv_init_script"
pyenv --version

# Install Python and pyenv virtualenvs
show_info "Checking and installing Python dependencies..."
Expand Down
Loading