From cc84aa7cbbc72d35aaf2d2423b66ab813152e458 Mon Sep 17 00:00:00 2001 From: "Doroszlai, Attila" Date: Thu, 30 Jul 2026 14:54:05 +0200 Subject: [PATCH] HDDS-16032. cd: lib/native: No such file or directory --- .../dist/src/shell/ozone/ozone-functions.sh | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh b/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh index 3260f6778070..c3991e9d1d39 100755 --- a/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh +++ b/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh @@ -1327,6 +1327,23 @@ function ozone_add_to_classpath_userpath fi } +function ozone_update_native_symlink +{ + if [ -z "$TARGET_FILE" ]; then + echo "Error: libhadoop doesn't support platform combination ($OS_TYPE / $ARCH_TYPE)." >&2 + return 1 + elif pushd "${OZONE_HOME}/lib/native" > /dev/null 2>&1; then + # Check if it already exists but points to the wrong target + if [ -L "$LINK_FILE" ] && [ "$(readlink "$LINK_FILE")" != "$TARGET_FILE" ]; then + # Forcefully recreate it so it points to the correct target file + ln -sf "$TARGET_FILE" "$LINK_FILE" > /dev/null 2>&1 + fi + popd > /dev/null + else + return 1 + fi +} + ## @description Routine to configure any OS-specific settings. ## @audience public ## @stability stable @@ -1352,20 +1369,10 @@ function ozone_os_tricks TARGET_FILE="libhadoop_osx_aarch_64.dylib" fi - pushd lib/native > /dev/null - # If no matching file variant was found for the current environment - if [ -z "$TARGET_FILE" ]; then - echo "Error: libhadoop doesn't support platform combination ($OS_TYPE / $ARCH_TYPE)." >&2 - else - LINK_FILE="libhadoop.dylib" - # Check if it already exists but points to the wrong target - if [ -L "$LINK_FILE" ] && [ "$(readlink "$LINK_FILE")" != "$TARGET_FILE" ]; then - # Forcefully recreate it so it points to the correct target file - ln -sf "$TARGET_FILE" "$LINK_FILE" > /dev/null 2>&1 - fi - export DYLD_LIBRARY_PATH=$OZONE_HOME/lib/native:$DYLD_LIBRARY_PATH + LINK_FILE="libhadoop.dylib" + if ozone_update_native_symlink; then + export DYLD_LIBRARY_PATH="${OZONE_HOME}/lib/native":$DYLD_LIBRARY_PATH fi - popd > /dev/null ;; Linux) @@ -1381,21 +1388,10 @@ function ozone_os_tricks TARGET_FILE="libhadoop_linux_x86_64.so" fi - pushd . > /dev/null && cd lib/native - # If no matching file variant was found for the current environment - if [ -z "$TARGET_FILE" ]; then - echo "Error: libhadoop doesn't support platform combination ($OS_TYPE / $ARCH_TYPE)." >&2 - else - LINK_FILE="libhadoop.so" - - # Check if it already exists but points to the wrong target - if [ -L "$LINK_FILE" ] && [ "$(readlink "$LINK_FILE")" != "$TARGET_FILE" ]; then - # Forcefully recreate it so it points to the correct target file - ln -sf "$TARGET_FILE" "$LINK_FILE" > /dev/null 2>&1 - fi - export LD_LIBRARY_PATH=$OZONE_HOME/lib/native:$LD_LIBRARY_PATH + LINK_FILE="libhadoop.so" + if ozone_update_native_symlink; then + export LD_LIBRARY_PATH="${OZONE_HOME}/lib/native":$LD_LIBRARY_PATH fi - popd > /dev/null ;; CYGWIN*) # Flag that we're running on Cygwin to trigger path translation later.