1212# Exits if error occurs
1313set -e
1414
15- # Set tab-spaces
16- tabs 4
15+ # Set tab-spaces (ignore errors in non-interactive terminals)
16+ tabs 4 2> /dev/null || true
1717
1818# get source directory
1919export ISAACLAB_PATH=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) "
@@ -232,8 +232,8 @@ extract_isaacsim_exe() {
232232
233233# find pip command based on virtualization
234234extract_pip_command () {
235- # detect if we're in a uv environment
236- if [ -n " ${VIRTUAL_ENV} " ] && [ -f " ${VIRTUAL_ENV} /pyvenv.cfg" ] && grep -q " uv " " ${VIRTUAL_ENV} /pyvenv.cfg" ; then
235+ # detect if we're in a uv environment - use precise pattern matching
236+ if [ -n " ${VIRTUAL_ENV} " ] && [ -f " ${VIRTUAL_ENV} /pyvenv.cfg" ] && grep -qE ' ^uv\s*= ' " ${VIRTUAL_ENV} /pyvenv.cfg" ; then
237237 pip_command=" uv pip install"
238238 else
239239 # retrieve the python executable
@@ -245,8 +245,8 @@ extract_pip_command() {
245245}
246246
247247extract_pip_uninstall_command () {
248- # detect if we're in a uv environment
249- if [ -n " ${VIRTUAL_ENV} " ] && [ -f " ${VIRTUAL_ENV} /pyvenv.cfg" ] && grep -q " uv " " ${VIRTUAL_ENV} /pyvenv.cfg" ; then
248+ # detect if we're in a uv environment - use precise pattern matching
249+ if [ -n " ${VIRTUAL_ENV} " ] && [ -f " ${VIRTUAL_ENV} /pyvenv.cfg" ] && grep -qE ' ^uv\s*= ' " ${VIRTUAL_ENV} /pyvenv.cfg" ; then
250250 pip_uninstall_command=" uv pip uninstall"
251251 else
252252 # retrieve the python executable
@@ -453,6 +453,14 @@ setup_uv_env() {
453453 local env_name=" $1 "
454454 local python_path=" $2 "
455455
456+ # check if already in a uv environment - use precise pattern matching
457+ if [ -n " ${VIRTUAL_ENV} " ] && [ -f " ${VIRTUAL_ENV} /pyvenv.cfg" ] && grep -qE ' ^uv\s*=' " ${VIRTUAL_ENV} /pyvenv.cfg" ; then
458+ echo " [INFO] Detected active uv environment at: ${VIRTUAL_ENV} "
459+ echo " [INFO] You can directly install Isaac Lab using: ./isaaclab.sh -i"
460+ echo " [INFO] If you want to create a new environment instead, deactivate the current one first."
461+ return 0
462+ fi
463+
456464 # check uv is installed
457465 if ! command -v uv & > /dev/null; then
458466 echo " [ERROR] uv could not be found. Please install uv and try again."
@@ -529,7 +537,8 @@ print_help () {
529537 echo -e " \nusage: $( basename " $0 " ) [-h] [-i] [-f] [-p] [-s] [-t] [-o] [-v] [-d] [-n] [-c] [-u] -- Utility to manage Isaac Lab."
530538 echo -e " \noptional arguments:"
531539 echo -e " \t-h, --help Display the help content."
532- echo -e " \t-i, --install [LIB] Install the extensions inside Isaac Lab and learning frameworks as extra dependencies. Default is 'all'."
540+ echo -e " \t-i, --install [LIB] Install the extensions inside Isaac Lab and learning frameworks as extra dependencies."
541+ echo -e " \t Can be used in any active conda/uv environment. Default is 'all'."
533542 echo -e " \t-f, --format Run pre-commit to format the code and check lints."
534543 echo -e " \t-p, --python Run the python executable provided by Isaac Sim or virtual environment (if active)."
535544 echo -e " \t-s, --sim Run the simulator executable (isaac-sim.sh) provided by Isaac Sim."
@@ -538,8 +547,16 @@ print_help () {
538547 echo -e " \t-v, --vscode Generate the VSCode settings file from template."
539548 echo -e " \t-d, --docs Build the documentation from source using sphinx."
540549 echo -e " \t-n, --new Create a new external project or internal task from template."
541- echo -e " \t-c, --conda [NAME] Create the conda environment for Isaac Lab. Default name is 'env_isaaclab'."
542- echo -e " \t-u, --uv [NAME] Create the uv environment for Isaac Lab. Default name is 'env_isaaclab'."
550+ echo -e " \t-c, --conda [NAME] Create a new conda environment for Isaac Lab. Default name is 'env_isaaclab'."
551+ echo -e " \t-u, --uv [NAME] Create a new uv environment for Isaac Lab. Default name is 'env_isaaclab'."
552+ echo -e " \nExamples:"
553+ echo -e " \t# Install in an existing uv environment:"
554+ echo -e " \t source /path/to/your/env/bin/activate"
555+ echo -e " \t ./isaaclab.sh -i"
556+ echo -e " \n\t# Create and setup a new uv environment:"
557+ echo -e " \t ./isaaclab.sh -u my_env"
558+ echo -e " \t source my_env/bin/activate"
559+ echo -e " \t ./isaaclab.sh -i"
543560 echo -e " \n" >&2
544561}
545562
@@ -567,6 +584,16 @@ while [[ $# -gt 0 ]]; do
567584 python_exe=$( extract_python_exe)
568585 pip_command=$( extract_pip_command)
569586 pip_uninstall_command=$( extract_pip_uninstall_command)
587+
588+ # show which environment is being used
589+ if [ -n " ${VIRTUAL_ENV} " ]; then
590+ echo " [INFO] Using uv/venv environment: ${VIRTUAL_ENV} "
591+ elif [ -n " ${CONDA_PREFIX} " ]; then
592+ echo " [INFO] Using conda environment: ${CONDA_PREFIX} "
593+ else
594+ echo " [INFO] Using Isaac Sim Python or system Python"
595+ fi
596+ echo " [INFO] Python executable: ${python_exe} "
570597
571598 # if on ARM arch, temporarily clear LD_PRELOAD
572599 # LD_PRELOAD is restored below, after installation
@@ -649,8 +676,22 @@ while [[ $# -gt 0 ]]; do
649676 uv_env_name=$2
650677 shift # past argument
651678 fi
679+ # determine python version based on Isaac Sim version with fallback
680+ if is_isaacsim_version_4_5 2> /dev/null; then
681+ python_version=" 3.10"
682+ echo " [INFO] Detected Isaac Sim 4.5 → Using Python version: ${python_version} "
683+ else
684+ python_version=" 3.11"
685+ # Check if we can detect Isaac Sim 5.0+
686+ if command -v python & > /dev/null && python -c " import isaacsim" 2> /dev/null; then
687+ echo " [INFO] Detected Isaac Sim 5.0+ → Using Python version: ${python_version} "
688+ else
689+ echo " [INFO] Isaac Sim not detected. Defaulting to Python version: ${python_version} "
690+ echo " [INFO] Note: Python 3.11 works with Isaac Sim 5.0+. Use Python 3.10 for Isaac Sim 4.5."
691+ fi
692+ fi
652693 # setup the uv environment for Isaac Lab
653- setup_uv_env ${uv_env_name}
694+ setup_uv_env ${uv_env_name} ${python_version}
654695 shift # past argument
655696 ;;
656697 -f|--format)
0 commit comments