isaac-sim / IsaacLab

Unified framework for robot learning built on NVIDIA Isaac Sim
https://isaac-sim.github.io/IsaacLab
Other
1.91k stars 735 forks source link

[Bug Report] conda activate orbit using incorrect path for setup_python_env.sh #407

Closed mattmazzola closed 4 months ago

mattmazzola commented 4 months ago

If you are submitting a bug report, please fill in the following details and use the tag [bug].

Describe the bug

Another issue noticed when attempting to resolve installations issue described in #406

When attempting to activate orbit environment, it fails to find setup_python_env.sh because it is looking in the current, Orbit repo directory instead of the _isaac_sim symbolic linked directory where it should.

Steps to reproduce

Please try to provide a minimal example to reproduce the bug. Error messages and stack traces are also helpful.

conda activate orbit
/home/mattm/repos/orbit/_isaac_sim/setup_conda_env.sh:.:20: no such file or directory: /home/mattm/repos/orbit/setup_python_env.sh```

setup_conda_env.sh

#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MY_DIR="$(realpath -s "$SCRIPT_DIR")"
# path=$SCRIPT_DIR
# while [[ $path != / ]];
# do

#     if ! find "$path" -maxdepth 1 -mindepth 1 -iname "_build" -exec false {} +
#     then
#         break
#     fi
#     # Note: if you want to ignore symlinks, use "$(realpath -s "$path"/..)"
#     path="$(readlink -f "$path"/..)"

# done
# build_path=$path/_build
export CARB_APP_PATH=$SCRIPT_DIR/kit
export EXP_PATH=$MY_DIR/apps
export ISAAC_PATH=$MY_DIR
. ${MY_DIR}/setup_python_env.sh

Work around?

Running conda activate orbit from the ISAACSIM_PATH allows the script to find the setup_python_env.sh file; however, I don't think this should be required

System Info

Describe the characteristic of your environment:

Additional context

Add any other context about the problem here.

Checklist

mattmazzola commented 4 months ago

Upon further investigation I think the issue is with the use of BASH_SOURCE[0] I am using Zsh and this variable is not defined when running the script resulting in the wrong path being set for $MY_DIR thus the wrong path to find setup_python_env.sh

I changed ${BASH_SOURCE[0]}" to $0 and added log statements to verify, and conda activate seems to work now!

(orbit) ➜  orbit git:(main) ✗ conda deactivate    
(base) ➜  orbit git:(main) ✗ conda activate orbit
BASH_SOURCE_0: 
0: /home/mattm/repos/orbit/_isaac_sim/setup_conda_env.sh

It looks like BASH_SOURCE[0] is used in different places throughout the repo which may mean this problem would exist in many places.

Solution

I think setup_conda_env.sh comes from installation of Isaac sim so I am not sure where to send PR to fix, but this is what I arrived at so both Bash and Zsh (and hopefully others work)

if [ -n "$BASH_VERSION" ]; then
    # Bash
    SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
else
    # Fallback for other shells
    SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
fi
mattmazzola commented 4 months ago

The above comment only solved the issue about activating orbit environment. However, it did not fix the issue with modules.

Here is more complete solution: https://github.com/NVIDIA-Omniverse/orbit/issues/103#issuecomment-1662112177