Skip to content

Activate ROS on Windows when conda runs in Git Bash / MSYS2 / Cygwin - #183

Merged
Tobias-Fischer merged 3 commits into
RoboStack:masterfrom
Tobias-Fischer:fix/win-bash-activation
Oct 26, 2026
Merged

Tobias-Fischer merged 3 commits into
RoboStack:masterfrom
Tobias-Fischer:fix/win-bash-activation

Conversation

@Tobias-Fischer

Copy link
Copy Markdown
Contributor

Fixes #182: with conda (not pixi) in Git Bash on Windows, a RoboStack environment's ROS activation doesn't run.

conda's posix activator runs only etc/conda/activate.d/*.sh, also on Windows (PosixActivator, script_extension=".sh"), but bld_catkin.bat.in installs only the .bat/.ps1 scripts for ros_workspace. The published win-64 ros2-ros-workspace has no .sh activation scripts.

This change:

  • bld_catkin.bat.in: also installs activate.sh/deactivate.sh on Windows.
  • activate.sh.in: a Windows branch ($OSTYPE msys*/cygwin*) that does what activate.bat → local_setup.bat does. It runs ament's Library/_local_setup_util.py in sh mode with the env's python.exe, so every package's .dsv hooks apply. Values stay in Windows form for native programs; only PATH entries are converted with cygpath, and leading/trailing separators are stripped as ;. It then sets ROS_OS_OVERRIDE, ROS_ETC_DIR, AMENT_PREFIX_PATH and AMENT_PYTHON_EXECUTABLE like activate.bat. The Unix branch is unchanged (only re-indented).
  • deactivate.sh.in: on Windows, also unsets what the Windows branch sets (as deactivate.bat).

Testing: only emulated, not yet on real Windows.

  • Templates render through vinca's generate_template; bash -n, dash -n and zsh -n pass.
  • An emulated Git Bash env built from the real win-64 ros_workspace/ros_environment packages, with OSTYPE=msys, a fake cygpath and a python.exe stand-in emitting Windows paths with CRLF line endings. It sets ROS_DISTRO, ROS_VERSION, ROS_PYTHON_VERSION, AMENT_PREFIX_PATH, PYTHONPATH and the rest; activating twice adds no duplicates; deactivation clears them. The Unix branch behaves as before against the linux-64 package.
  • Needs a check with conda in real Git Bash (e.g. find_package(rclcpp) from the issue) before merging.

Not covered here: PowerShell (RoboStack/ros-humble#108). activate.ps1 calls Library\local_setup.ps1, which isn't installed (ament generates only .bat on Windows), so ROS_DISTRO/ROS_VERSION/PYTHONPATH aren't set there either; that needs a separate fix.

Once merged: bump the vinca pin in RoboStack/robostack and ros_workspace's build number per distribution.

🤖 Generated with Claude Code

conda's posix activator runs only etc/conda/activate.d/*.sh, also on
Windows, but ros_workspace installed only the .bat/.ps1 scripts there
(bld_catkin.bat.in), so a conda env activated from Git Bash got no ROS
environment (RoboStack#182).

Install activate.sh/deactivate.sh on Windows too and give them a Windows
branch that does what activate.bat -> local_setup.bat does: run ament's
_local_setup_util.py in "sh" mode to evaluate every package's .dsv hooks,
keep values in Windows form for native programs, convert PATH entries
with cygpath, and strip ';' (not ':') separators. The Unix branch is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tobias-Fischer

Copy link
Copy Markdown
Contributor Author

@traversaro - could you please take a look at this? I couldn't check locally.

@traversaro

Copy link
Copy Markdown
Member

@Tobias-Fischer done, I Added some tests and checked it works on Windows.

@Tobias-Fischer

Copy link
Copy Markdown
Contributor Author

Amazing thank you @traversaro

@Tobias-Fischer
Tobias-Fischer merged commit 25d7b42 into RoboStack:master Oct 26, 2026
3 checks passed
@Tobias-Fischer
Tobias-Fischer deleted the fix/win-bash-activation branch October 26, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No activation scripts on Windows for Git Bash on conda

2 participants