RoboStack / robostack.github.io

180 stars 20 forks source link

How to Automatically Source devel/setup.zsh After Activating ros_env Environment? #43

Closed desstiony closed 8 months ago

desstiony commented 8 months ago

I'm working with ROS and have set up my development environment using mamba activate ros_env. However, I find myself repeatedly sourcing devel/setup.zsh every time I activate the environment to ensure that ROS packages are properly sourced in my shell. Is there a way to automate the sourcing of devel/setup.zsh upon activating the ros_env environment?

traversaro commented 8 months ago

I do not know if it is a failproof method, but what we typically do in my lab is to manually add an activation script with the package activation scripts of the conda environment, something like:

echo "source $(pwd)/devel/setup.zsh" > "${CONDA_PREFIX}/etc/conda/activate.d/choose_unique_name_for_this_prefix_activate.sh"
chmod +x "${CONDA_PREFIX}/etc/conda/activate.d/choose_unique_name_for_this_prefix_activate.sh"

However, after disk the deactivate of your conda environment will not properly work anymore.

Tobias-Fischer commented 8 months ago

You can use this: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#macos-and-linux

Feel free to reopen if you have more questions