Termux (Terminal) tsu is adding "(unreachable)" to my current working path When I run tsu (which is Termux's version of su), my current working directory gets prefixed with &quot;(unreachable)&quot;, as you can see from the transcript of my session.
[u0_a116 …/~]$ tsu
[root …/home]# pwd
(unreachable)/data/data/com.termux/files/home
[root …/home]#

I did some digging and found what seems to me is the culprit.
tsu is a script that sets up an environment for the root user and then runs su to give you root privilege with the new environment. This is what the command that tsu is running looks like after opening all the variables.
/sbin/su -c PATH=/sbin/.magisk/busybox env -i PATH=/data/data/com.termux/files/usr/bin:/data    /data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin     ANDROID_DATA=/data TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp PREFIX=/    data/data/com.termux/files/usr TERM=xterm-256color LD_PRELOAD=/data/data/com.ter    mux/files/usr/lib/libtermux-exec.so ANDROID_ROOT=/system HOME=/data/data/com.ter    mux/files/home/.suroot /data/data/com.termux/files/usr/bin/bash
This causes a problem when I try to run a script that is using relative paths. (I'm running a script to setup a full linux distro with proot in Termux).
If I take out the 'env -i` from the command then I get the current working directory without the prefixed &quot;(unreachable)&quot;. This does not setup the new environment, it leaves the old environment intact as if I would have selected --preserve option.
I have had the same problem. I resolved it with a work around. I added to the environment the following.
PWD=$(echo $PWD | cut -c 14-)
I added the following lines to the tsu script at line numbers 239 - 241
# Following line added to fix the problem of pwd starting with (unreachable)
ENV_BUILT+=&quot; PWD=$(echo $PWD | cut -c 14-)&quot;


Following is the the full code of the updated tsu script

#!/data/data/com.termux/files/usr/bin/bash

# Copyright (c) 2020, Cswl C. https://github.com/cswl
# This software is licensed under the ISC Liscense.
# https://github.com/cswl/tsu/blob/v8/LICENSE.md

### tsu
_TSU_VERSION=&quot;8.5.1&quot;

log_DEBUG() { __debug_wrapper() { :; }; }

gather_debug_info() {
    echo &quot;Environment: &quot;
    env
    echo &quot;============================&quot;
    dpkg --print-architecture
    echo &quot;Android version:&quot;
    getprop ro.build.version.release
    echo &quot;Android device:&quot;
    getprop ro.product.manufacturer
    getprop ro.product.model
    uname -a

} &gt;&gt;&quot;$LOG_FILE&quot;

# Allow debugging with a long option
if [[ &quot;$1&quot; == '--dbg' ]]; then
    _TSU_DEBUG=true
    printf -v LOG_FILE &quot;%(%Y%m%d)T&quot;
    LOG_FILE=&quot;./tsu_debug_$LOG_FILE&quot;
    gather_debug_info
    set -x
    shift
fi

## Support for busybox style calling convention.
## This works because we don't actually `readlink` the script location.
_TSU_CALL=&quot;${BASH_SOURCE[0]##*/}&quot;
if [[ &quot;$_TSU_CALL&quot; == &quot;sudo&quot; ]]; then
    _TSU_AS_SUDO=true
fi

show_usage() {
    cat &lt;&lt;&quot;EOF&quot;
tsu A su interface wrapper for Termux

    Usage:
        tsu
        tsu [ -s SHELL ]  [-p|-a] [USER]
        tsu --dbg [ -s SHELL ] [-p|-a] [-E] [USER]
        tsu -h | --help | --version

    Options:
    --dbg        Enable debug output
    -s &lt;shell&gt;   Use an alternate specified shell.
    -p           Prepend system binaries to PATH
    -a           Append system binaries to PATH
    -h --help    Show this screen.

    This package also provides a minimal sudo which is enough to run most programs as root

        sudo command

    https://github.com/cswl/tsu 

EOF
}

show_usage_sudo() {
    cat &lt;&lt;&quot;EOF&quot;
sudo - run commands as root or another user 
  usage: sudo command 
  usage: sudo [-E] [-u USER] command 

    Options:
      -E          Preserve environment variables from the current shell.
      -u USER   Switch to USER instead of root..
EOF
}

# Defaults in Termux and Android
TERMUX_FS=&quot;/data/data/com.termux/files&quot;
TERMUX_PREFIX=&quot;$TERMUX_FS/usr&quot;
TERMUX_PATH=&quot;$TERMUX_PREFIX/bin:$TERMUX_PREFIX/bin/applets&quot;
ROOT_HOME=&quot;$TERMUX_FS/home/.suroot&quot;
ANDROID_SYSPATHS=&quot;/system/bin:/system/xbin&quot;
EXTRA_SYSPATHS=&quot;/sbin:/sbin/bin&quot;
#ANDROID_ASROOT_SYSPATHS=&quot;/bin:/xbin&quot;

# Some constants that may change in future.
BB_MAGISK=&quot;/sbin/.magisk/busybox&quot;

# Options parsing

# Loop through arguments and process them
log_DEBUG TSU_AS_SUDO
if [[ &quot;$_TSU_AS_SUDO&quot; == true ]]; then
    # Handle cases where people do `sudo su`
    if [[ &quot;$1&quot; == &quot;su&quot; ]]; then
        unset _TSU_AS_SUDO
    fi

    _is_pos() {
        for e in -u --user -E --preserve-enviroment; do [[ &quot;$e&quot; == &quot;$1&quot; ]] &amp;&amp; return 1; done
        return 0
    }

    for arg in &quot;$@&quot;; do

        # It is important to break as soon as we see a positional argument
        # Otherwise `sudo id -u` or `sudo some_cmd -E` wont work as expected

        if _is_pos &quot;$arg&quot;; then break; fi

        case $arg in
        -u | --user)
            SWITCH_USER=&quot;$2&quot;
            shift
            shift
            ;;
        -E | --preserve-enviroment)
            ENVIRONMENT_PRESERVE=true
            shift
            ;;
        esac
    done

fi

log_DEBUG _TSU_AS_SUDO
if [[ -z &quot;$_TSU_AS_SUDO&quot; ]]; then
    for arg in &quot;$@&quot;; do
        case $arg in
        -p | --syspre)
            PREPEND_SYSTEM_PATH=true
            shift
            ;;
        -a | --sysadd)
            APPEND_SYSTEM_PATH=true
            shift
            ;;
        -s | --shell)
            ALT_SHELL=&quot;$2&quot;
            shift
            shift
            ;;
        --version)
            echo &quot;tsu - $_TSU_VERSION&quot;
            exit
            ;;
        -h | --help)
            show_usage
            exit
            ;;

        *)
            POS_ARGS+=(&quot;$1&quot;)
            shift
            ;;
        esac
    done

    SWITCH_USER=&quot;${POS_ARGS[0]}&quot;
fi

declare -A EXP_ENV

env_path_helper() {

    # We will try to match the default behavior of normal linux su
    # Unless the user specifically asks to preserve the enviroment,
    # We create a fresh new one.
    log_DEBUG &quot;${FUNCNAME[0]}&quot;

    log_DEBUG SWITCH_USER
    if [[ -z &quot;$SWITCH_USER&quot; ]]; then
        ## By default we start a fresh root shell with HOME set to that of the root home

        # Creat root $HOME if it doesnt exsists yet
        [[ -d &quot;$ROOT_HOME&quot; ]] || mkdir &quot;$ROOT_HOME&quot;
        NEW_HOME=&quot;$ROOT_HOME&quot;

        EXP_ENV[PREFIX]=&quot;$PREFIX&quot;
        EXP_ENV[TMPDIR]=&quot;$ROOT_HOME/.tmp&quot;
        EXP_ENV[LD_PRELOAD]=&quot;$LD_PRELOAD&quot;

        log_DEBUG _TSU_AS_SUDO
        if [[ &quot;$_TSU_AS_SUDO&quot; == true ]]; then
            # sudo copies PATH variable, so most user binaries can run as root
            # tested with `sudo env` version 1.8.31p1
            NEW_PATH=&quot;$PATH&quot;
            EXP_ENV[SUDO_GID]=&quot;$(id -g)&quot;
            EXP_ENV[SUDO_USER]=&quot;$(id -un)&quot;
            EXP_ENV[SUDO_USER]=&quot;$(id -u)&quot;
        else
            NEW_PATH=&quot;$TERMUX_PATH&quot;
        fi

        # Android versions prior to 7.0 will break if LD_LIBRARY_PATH is set
        log_DEBUG &quot;LD_LIBRARY_PATH&quot;
        if [[ -n &quot;$LD_LIBRARY_PATH&quot; ]]; then
            SYS_LIBS=&quot;/system/lib64&quot;
            EXP_ENV[LD_LIBRARY_PATH]=&quot;$LD_LIBRARY_PATH:$SYS_LIBS&quot;
        else
            ASP=&quot;${ANDROID_SYSPATHS}:${EXTRA_SYSPATHS}&quot;
            # Should we add /system/* paths:
            # Some Android utilities work. but some break
            log_DEBUG &quot;PREPEND_SYSTEM_PATH&quot;
            if [[ -n &quot;$PREPEND_SYSTEM_PATH&quot; ]]; then
                NEW_PATH=&quot;$ASP:$NEW_PATH&quot;
            else
                NEW_PATH=&quot;$NEW_PATH:$ASP&quot;
            fi
        fi

    else
        # Other uid in the system cannot run Termux binaries
        NEW_HOME=&quot;/&quot;
        NEW_PATH=&quot;$ANDROID_SYSPATHS&quot;

    fi

    # We create a new environment cause the one on the
    # user Termux enviroment may be polluted with startup scripts
    EXP_ENV[PATH]=&quot;$NEW_PATH&quot;
    EXP_ENV[HOME]=&quot;$NEW_HOME&quot;
    EXP_ENV[TERM]=&quot;xterm-256color&quot;

    [[ -z &quot;$_TSU_DEBUG&quot; ]] || set +x
    ## Android specific exports: Need more testing.
    EXP_ENV[ANDROID_ROOT]=&quot;$ANDROID_ROOT&quot;
    EXP_ENV[ANDROID_DATA]=&quot;$ANDROID_DATA&quot;

    ENV_BUILT=&quot;&quot;

    for key in &quot;${!EXP_ENV[@]}&quot;; do
        ENV_BUILT=&quot;$ENV_BUILT $key=${EXP_ENV[$key]} &quot;
    done

    # Following line added to fix the problem of pwd starting with (unreachable)
    ENV_BUILT+=&quot; PWD=$(echo $PWD | cut -c 14-)&quot;

    [[ -z &quot;$_TSU_DEBUG&quot; ]] || set -x

}

root_shell_helper() {
    log_DEBUG &quot;${FUNCNAME[0]}&quot;

    if [[ -n &quot;$SWITCH_USER&quot; ]]; then
        ROOT_SHELL=&quot;/system/bin/sh&quot;
        return
    fi
    # Selection of shell, checked in this order.
    # user defined shell -&gt; user's login shell
    # bash -&gt;  sh
    log_DEBUG &quot;ALT_SHELL&quot;
    if [[ &quot;$ALT_SHELL&quot; == &quot;system&quot; ]]; then
        ROOT_SHELL=&quot;/system/bin/sh&quot;
    elif [[ -n &quot;$ALT_SHELL&quot; ]]; then
        # Expand //usr/ to /usr/
        ALT_SHELL_EXPANDED=&quot;${ALT_SHELL/\/usr\//$TERMUX_PREFIX\/}&quot;
        ROOT_SHELL=&quot;$ALT_SHELL_EXPANDED&quot;
    elif [[ -x &quot;$HOME/.termux/shell&quot; ]]; then
        ROOT_SHELL=&quot;$(readlink -f -- &quot;$HOME/.termux/shell&quot;)&quot;
    elif [[ -x &quot;$PREFIX/bin/bash&quot; ]]; then
        ROOT_SHELL=&quot;$PREFIX/bin/bash&quot;
    else
        ROOT_SHELL=&quot;$PREFIX/bin/sh&quot;
    fi
}

log_DEBUG _TSU_AS_SUDO
if [[ &quot;$_TSU_AS_SUDO&quot; == true ]]; then
    if [[ -z &quot;$1&quot; ]]; then
        show_usage_sudo
        exit 1
    fi
    CMD_ARGS=$(printf '%q ' &quot;$@&quot;)
    log_DEBUG ENVIRONMENT_PRESERVE
    [[ -n &quot;$ENVIRONMENT_PRESERVE&quot; ]] || env_path_helper

    STARTUP_SCRIPT=&quot;$CMD_ARGS&quot;
else

    root_shell_helper
    env_path_helper

    STARTUP_SCRIPT=&quot;$ROOT_SHELL&quot;
fi

SU_BINARY_SEARCH=(&quot;/system/xbin/su&quot; &quot;/system/bin/su&quot;)

# On some systems with other root methods `/sbin` is inacessible.
if [[ -x &quot;/sbin&quot; ]]; then
    SU_BINARY_SEARCH+=(&quot;/sbin/su&quot; &quot;/sbin/bin/su&quot;)
else
    SKIP_SBIN=1
fi

# Unset all Termux LD_* enviroment variables to prevent symbols missing , dlopen()ing of wrong libs.
unset LD_LIBRARY_PATH
unset LD_PRELOAD

### ----- MAGISKSU
# shellcheck disable=SC2117
if [[ -z &quot;$SKIP_SBIN&quot; &amp;&amp; &quot;$(/sbin/su -v)&quot; == *&quot;MAGISKSU&quot; ]]; then
    # We are on Magisk su
    su_args=(&quot;/sbin/su&quot;)
    [[ -z &quot;$SWITCH_USER&quot; ]] || su_args+=(&quot;$SWITCH_USER&quot;)

    su_cmdline=&quot;PATH=$BB_MAGISK &quot;
    if [[ -n &quot;$ENVIRONMENT_PRESERVE&quot; ]]; then
        su_args+=(&quot;--preserve-environment&quot;)
        su_cmdline+=&quot;$STARTUP_SCRIPT&quot;
    else
        su_cmdline+=&quot;env -i $ENV_BUILT $STARTUP_SCRIPT&quot;
    fi
    su_args+=(&quot;-c&quot;)
    exec &quot;${su_args[@]}&quot; &quot;${su_cmdline}&quot;
    ##### ----- END MAGISKSU
else
    ##### ----- OTHERS SU
    for SU_BINARY in &quot;${SU_BINARY_SEARCH[@]}&quot;; do
        if [[ -x &quot;$SU_BINARY&quot; ]]; then

            su_args=(&quot;$SU_BINARY&quot;)
            [[ -z &quot;$SWITCH_USER&quot; ]] || su_args+=(&quot;$SWITCH_USER&quot;)

            # Let's use the system toybox/toolbox for now
            su_cmdline=&quot;PATH=$ANDROID_SYSPATHS &quot;
            if [[ -n &quot;$ENVIRONMENT_PRESERVE&quot; ]]; then
                su_args+=(&quot;--preserve-environment&quot;)
                su_cmdline+=&quot;$STARTUP_SCRIPT &quot;
            else
                su_cmdline+=&quot;env -i $ENV_BUILT $STARTUP_SCRIPT&quot;
            fi
            su_args+=(&quot;-c&quot;)
            exec &quot;${su_args[@]}&quot; &quot;${su_cmdline}&quot;
        fi
    done
fi
##### ----- END OTHERS SU

# We didnt find any su binary
set +x
printf -- &quot;No superuser binary detected. \n&quot;
printf -- &quot;Are you rooted? \n&quot;

if [[ -n &quot;$_TSU_DEBUG&quot; ]]; then
    echo &quot;-------------------------------------&quot;
    echo &quot;tsu ran in debug mode.&quot;
    echo &quot;Full log can be found in tsu_debug.log&quot;
    echo &quot;Report any issues to: https://github.com/cswl/tsu &quot;
fi

exit 1