From 4c3ac9e6bd90b0b4c00e45ce7498a4438082af9d Mon Sep 17 00:00:00 2001 From: Henry Priest Date: Thu, 26 Feb 2026 14:26:35 -0600 Subject: [PATCH] added kernel_root option added R_LIBS to the set of env vars which are null'd when discovering the correct kernel path. --- icrn_manager | 2 +- kernel-indexer/entrypoint.sh | 10 +++++++++- tests/test_common.sh | 2 ++ tests/test_config.sh | 6 +++++- tests/test_help.sh | 13 ++++++++++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/icrn_manager b/icrn_manager index 812edaa..3d3c85e 100755 --- a/icrn_manager +++ b/icrn_manager @@ -508,7 +508,7 @@ function register_r_library_in_user_catalog() # without unpacking, identify R ke # "R_HOME=''" ensures we don't get complaints from R that R_HOME is set, but we're calling a Rscript that isn't located there # we want to get a very plain readout of where this R install's main kernel is. echo "getting R path." - target_kernel_path=$(R_HOME='' R_LIBS_USER='' R_LIBS_SITE='' $target_unpacked/bin/Rscript --vanilla -e 'cat(.libPaths()[1])') + target_kernel_path=$(R_LIBS='' R_HOME='' R_LIBS_USER='' R_LIBS_SITE='' $target_unpacked/bin/Rscript --vanilla -e 'cat(.libPaths()[1])') echo "determined: $target_kernel_path" echo "Updating user's catalog with $target_kernel_path" diff --git a/kernel-indexer/entrypoint.sh b/kernel-indexer/entrypoint.sh index 88ac988..bee41ca 100644 --- a/kernel-indexer/entrypoint.sh +++ b/kernel-indexer/entrypoint.sh @@ -15,7 +15,15 @@ DEFAULT_KERNEL_ROOT="/sw/icrn/jupyter/icrn_ncsa_resources/Kernels" # Environment variables with defaults KERNEL_ROOT="${KERNEL_ROOT:-${DEFAULT_KERNEL_ROOT}}" -KERNEL_ROOT_HOST="${KERNEL_ROOT_HOST:-${KERNEL_ROOT}}" +# When running in container with standard mount (/app/data), use host path for catalog entries +# so catalog paths are valid on the host/NFS, not inside the container. +if [ -n "${KERNEL_ROOT_HOST:-}" ]; then + : # use explicit KERNEL_ROOT_HOST +elif [ "${KERNEL_ROOT}" = "/app/data" ]; then + KERNEL_ROOT_HOST="/sw/icrn/dev/kernels" +else + KERNEL_ROOT_HOST="${KERNEL_ROOT}" +fi OUTPUT_DIR="${OUTPUT_DIR:-${KERNEL_ROOT}}" LANGUAGE_FILTER="${LANGUAGE_FILTER:-}" LOG_LEVEL="${LOG_LEVEL:-INFO}" diff --git a/tests/test_common.sh b/tests/test_common.sh index cfe7c25..0241c11 100644 --- a/tests/test_common.sh +++ b/tests/test_common.sh @@ -241,11 +241,13 @@ cleanup_test_env() { } # Function to set test environment variables +# KERNEL_FOLDER must point to an existing directory or icrn_manager exits at startup. set_test_env() { export HOME="$TEST_USER_HOME" export ICRN_USER_BASE="$TEST_USER_HOME/.icrn" export ICRN_USER_KERNEL_BASE="$TEST_USER_HOME/.icrn/icrn_kernels" export ICRN_USER_CATALOG="$TEST_USER_HOME/.icrn/icrn_kernels/user_catalog.json" + export KERNEL_FOLDER="$TEST_REPO" } # Function to run icrn_manager with automatic confirmation for prompts diff --git a/tests/test_config.sh b/tests/test_config.sh index ed84d1e..b321906 100755 --- a/tests/test_config.sh +++ b/tests/test_config.sh @@ -82,9 +82,13 @@ test_config_validation_missing_repository() { local output output=$(icrn_manager_with_confirm kernels available 2>&1) - # Check if it fails with appropriate error - the script will try to read the catalog but fail + # Check if it fails with appropriate error. When KERNEL_FOLDER (still set to removed + # TEST_REPO) is no longer a directory, the script exits at startup with "Could not + # determine location of kernel respository". Otherwise we get main-block messages. if echo "$output" | grep -q "Couldn't locate.*kernel repository" || \ echo "$output" | grep -q "Please contact support" || \ + echo "$output" | grep -q "Could not determine location of kernel respository" || \ + echo "$output" | grep -q "contact administrator" || \ echo "$output" | grep -q "Could not open file" || \ echo "$output" | grep -q "No such file or directory"; then return 0 diff --git a/tests/test_help.sh b/tests/test_help.sh index ab89ec4..9d9b92b 100755 --- a/tests/test_help.sh +++ b/tests/test_help.sh @@ -5,8 +5,10 @@ source "$(dirname "$0")/test_common.sh" test_help_command() { + setup_test_env + set_test_env local output - output=$("$ICRN_MANAGER" help 2>&1) + output=$("$ICRN_MANAGER" help 2>&1 &1) + output=$("$ICRN_MANAGER" invalid_command 2>&1 &1) + # kernels (no subcommand) triggers check_and_init_if_needed -> kernels__init which prompts; pipe "y" + output=$(printf 'y\n' | "$ICRN_MANAGER" kernels 2>&1) # Check if it shows error for missing subcommand if echo "$output" | grep -q "Error: No subcommand specified" || \