fzi-forschungszentrum-informatik / robot_folders

robot_folders helps you managing multiple source projects with their own workspaces mainly around the ROS ecosystem.
MIT License
47 stars 4 forks source link

Allow chaining of workspaces #24

Closed fmauch closed 5 months ago

fmauch commented 6 months ago

Though it is not recommended to chain workspaces it might be desirable to source a workspace that us not the currently sourced one. With the changes introduced in version 0.5.0 this possibility was removed. This commit re-adds that functionality. The .cur_env file is always read independent of whether the ROB_FOLDERS_ACTIVE_ENV variable is set or not.

codecov-commenter commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 53.42%. Comparing base (077fd4d) to head (5d76444). Report is 9 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #24 +/- ## ========================================== + Coverage 45.84% 53.42% +7.58% ========================================== Files 26 27 +1 Lines 1444 1458 +14 ========================================== + Hits 662 779 +117 + Misses 782 679 -103 ``` | [Flag](https://app.codecov.io/gh/fzi-forschungszentrum-informatik/robot_folders/pull/24/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fzi-forschungszentrum-informatik) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/fzi-forschungszentrum-informatik/robot_folders/pull/24/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fzi-forschungszentrum-informatik) | `53.42% <ø> (+7.58%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fzi-forschungszentrum-informatik#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Oberacda commented 5 months ago

The current PR will cause the workspaces to become active at the same time: image

fmauch commented 5 months ago

Thank you @Oberacda! With the changes you provided, I think this is good to get merged.


Edit: Thinking about this a bit more:

This way, one could not alter the environment without robot_folders e.g. by manually sourcing a virtualenv or setting an installation path by hand. e.g.

### opening a new shell, current env is being cached away ###
ubuntu@jammy:~$ echo $PATH
/home/ubuntu/.node/bin:/home/ubuntu/.local/bin:/home/ubuntu/.node/bin:/home/ubuntu/.local/bin:/home/ubuntu/.local/bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/ubuntu/.fzf/bin
ubuntu@jammy:~$ source .local/pipx/venvs/sphinx-autobuild/bin/activate
(sphinx-autobuild) ubuntu@jammy:~$ echo $PATH
/home/ubuntu/.local/pipx/venvs/sphinx-autobuild/bin:/home/ubuntu/.node/bin:/home/ubuntu/.local/bin:/home/ubuntu/.node/bin:/home/ubuntu/.local/bin:/home/ubuntu/.local/bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/ubuntu/.fzf/bin
(sphinx-autobuild) ubuntu@jammy:~$ fzirob change_environment test_env 
rob_folders change_environment test_env
Sourcing environment '/home/ubuntu/checkout/test_env'
Sourcing /opt/ros/rolling/setup.bash
Sourced colcon workspace /home/ubuntu/checkout/test_env/colcon_ws
Sourced misc_ws workspace from /home/ubuntu/checkout/test_env/misc_ws
Environment setup for 'test_env' done. You now have a sourced environment.
(test_env) ubuntu@jammy:~$ echo $PATH
/home/ubuntu/checkout/test_env/misc_ws/export/bin:/opt/ros/rolling/bin:/home/ubuntu/.local/bin:/home/ubuntu/.node/bin:/home/ubuntu/.local/bin:/home/ubuntu/.local/bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/ubuntu/.fzf/bin
Oberacda commented 5 months ago

I think when souring the virtual env after robot folders, or within the setup_local.sh file, one can still alter the env. image

fmauch commented 5 months ago

I think when souring the virtual env after robot folders, or within the setup_local.sh file, one can still alter the env.

That's probably a fair point. I've added some documentation on this in 8eb1526. @Oberacda, do you think that makes things clear?