From 44440909dd4a66e93fa0b9caff5f1f1fec37f4f7 Mon Sep 17 00:00:00 2001 From: orphen Date: Thu, 24 Jun 2021 05:31:28 +0900 Subject: [PATCH] Fix path issues in ubuntu_setup.sh and openpilot_env.sh (#21380) * fix: fix pathing issues in ubuntu_setup.sh and openpilot_env.sh Fixes: - enter git tree before trying git operations in ubuntu_setup.sh - extend PYTHONPATH instead of overwriting it in openpilot_env.sh - fix pyenv pathing with workaround in openpilot_env.sh This also adds a newline before .bashrc extensions to visually separate the additions from existing content. * Update tools/ubuntu_setup.sh Co-authored-by: Adeeb Shihadeh old-commit-hash: 6d3c587564afe404031a7a14fc8b3431e1abb9bd --- tools/openpilot_env.sh | 11 ++++++++++- tools/ubuntu_setup.sh | 9 ++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/openpilot_env.sh b/tools/openpilot_env.sh index ca25706b83..ac784d41e2 100755 --- a/tools/openpilot_env.sh +++ b/tools/openpilot_env.sh @@ -1,9 +1,18 @@ if [ -z "$OPENPILOT_ENV" ]; then - export PYTHONPATH="$HOME/openpilot" + export PYTHONPATH="$HOME/openpilot:$PYTHONPATH" unamestr=`uname` if [[ "$unamestr" == 'Linux' ]]; then export PATH="$HOME/.pyenv/bin:$PATH" + + # Pyenv suggests we place the below two lines in .profile before we source + # .bashrc, but there is no simple way to guarantee we do this correctly + # programmatically across heterogeneous systems. For end-user convenience, + # we add the lines here as a workaround. + # https://github.com/pyenv/pyenv/issues/1906 + export PYENV_ROOT="$HOME/.pyenv" + eval "$(pyenv init --path)" + eval "$(pyenv virtualenv-init -)" elif [[ "$unamestr" == 'Darwin' ]]; then # msgq doesn't work on mac diff --git a/tools/ubuntu_setup.sh b/tools/ubuntu_setup.sh index 16893f6a20..fddfb2f5cb 100755 --- a/tools/ubuntu_setup.sh +++ b/tools/ubuntu_setup.sh @@ -68,18 +68,17 @@ if ! command -v "pyenv" > /dev/null 2>&1; then curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash fi -# install bashrc +# in the openpilot repo +cd $HOME/openpilot + source ~/.bashrc if [ -z "$OPENPILOT_ENV" ]; then OP_DIR=$(git rev-parse --show-toplevel) - echo "source $OP_DIR/tools/openpilot_env.sh" >> ~/.bashrc + printf "\nsource %s/tools/openpilot_env.sh" "$OP_DIR" >> ~/.bashrc source ~/.bashrc echo "added openpilot_env to bashrc" fi -# in the openpilot repo -cd $HOME/openpilot - # do the rest of the git checkout git lfs pull git submodule init