ros / catkin

A CMake-based build system that is used to build all packages in ROS.
http://wiki.ros.org/catkin
BSD 3-Clause "New" or "Revised" License
321 stars 280 forks source link

devel/setup.bash does not set `_CATKIN_SETUP_DIR` correctly in `zsh`. #1159

Closed RishabhGarg108 closed 2 years ago

RishabhGarg108 commented 2 years ago

After running source devel/setup.bash, I encountered the following error

devel/setup.bash:.:8: no such file or directory: /Users/ishanki/ros/learn_ws/setup.sh

I did some digging and I found out that

_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[1]}"`" > /dev/null && pwd)

command is setting _CATKIN_SETUP_DIR to the directory from which I run the source devel/setup.bash command.

I found on internet that for zsh, ${0:A:h} gives the directory of the source file. Then I tried the following command and it worked correctly for me:

_CATKIN_SETUP_DIR=$(builtin cd "${0:A:h}" > /dev/null && pwd)

I am not sure whether the earlier script was intended only for bash terminals or I did something wrong. Anyways, I thought it might be helpful to share this :)

ivanpauno commented 2 years ago

There's a setup.zsh in the same folder, you should be using that one instead. IIUC, the two files are needed because there isn't a way to get the source file directory that is compatible with both bash and zsh.

If this doesn't solve the issue, please let me know and we can reopen the ticket.