From 8d2bb3f418ccf3106ee4efb90d0a07bca1c04170 Mon Sep 17 00:00:00 2001 From: Rob Mohr Date: Tue, 31 Jan 2023 05:18:21 +0000 Subject: pw_env_setup: Clear PW_ENVIRONMENT_ROOT Clear PW_ENVIRONMENT_ROOT after bootstrap completes. This reduces the errors when switching between workspaces in the same terminal. Change-Id: I0b7300af99e29ffded79abdce19ef6c3917cf810 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/127032 Reviewed-by: Chad Norvell Commit-Queue: Auto-Submit Pigweed-Auto-Submit: Rob Mohr --- pw_env_setup/docs.rst | 3 ++- pw_env_setup/util.sh | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pw_env_setup/docs.rst b/pw_env_setup/docs.rst index fae85652a..9f6bee03f 100644 --- a/pw_env_setup/docs.rst +++ b/pw_env_setup/docs.rst @@ -431,7 +431,8 @@ never need to set these. ``PW_ENVIRONMENT_ROOT`` Location to which packages are installed. Defaults to ``environment`` folder - within the checkout root. + within the checkout root. This variable is cleared after environment setup is + complete. ``PW_ENVSETUP_DISABLE_SPINNER`` Disable the spinner during env setup. Intended to be used when the output is diff --git a/pw_env_setup/util.sh b/pw_env_setup/util.sh index a5b81f3fb..c6e66f1bb 100644 --- a/pw_env_setup/util.sh +++ b/pw_env_setup/util.sh @@ -110,11 +110,12 @@ pw_check_root() { } pw_get_env_root() { - # PW_ENVIRONMENT_ROOT allows developers to specify where the environment - # should be installed. bootstrap.sh scripts should not use that variable to - # store the result of this function. This separation allows scripts to assume - # PW_ENVIRONMENT_ROOT came from the developer and not from a previous - # bootstrap possibly from another workspace. + # PW_ENVIRONMENT_ROOT allows callers to specify where the environment should + # be installed. bootstrap.sh scripts should not use that variable to store the + # result of this function. This separation allows scripts to assume + # PW_ENVIRONMENT_ROOT came from the caller and not from a previous bootstrap + # possibly from another workspace. PW_ENVIRONMENT_ROOT will be cleared after + # environment setup completes. if [ -n "$PW_ENVIRONMENT_ROOT" ]; then echo "$PW_ENVIRONMENT_ROOT" return @@ -361,6 +362,7 @@ pw_cleanup() { unset PW_BANNER_FUNC unset _PW_ENV_SETUP unset _PW_NAME + unset PW_ENVIRONMENT_ROOT unset _PW_PYTHON unset _PW_ENV_ROOT_TXT unset _PW_PREV_ENV_ROOT -- cgit v1.2.3