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

setup.zsh fails, parse error: condition expected: 0 #1098

Closed trusktr closed 4 years ago

trusktr commented 4 years ago

I'm in ZSH in Manjaro Linux, and I'm new to ROS. I tried sourcing setup.sh but it results in an error:

❯ source /opt/ros/melodic/setup.sh
/opt/ros/melodic/setup.sh:pwd:77: too many arguments
/opt/ros/melodic/setup.sh:83: parse error: condition expected: 0

Same thing if I source the zsh file:

❯ source /opt/ros/melodic/setup.zsh
/opt/ros/melodic/setup.sh:pwd:77: too many arguments
/opt/ros/melodic/setup.sh:83: parse error: condition expected: 0

Any ideas? What info can I provide to get better help?

dirk-thomas commented 4 years ago

I can't reproduce the problem.

What version of the catkin package are you using? If it is not the latest one from Melodic (currently 0.7.26) please try it again with that version.

What info can I provide to get better help?

You try modifying the shell script to e.g. not delete the temporary script which is invoked in line 77 and instead prints its paths and investigate its content to see what is going wrong for you.

trusktr commented 4 years ago

I am on catkin 0.7.25. I installed with my distros package manager (pamac, which builds ros-melodic-catkin from ArchLinux AUR).

Taking a look at the file. Why would it try to rm -rf the file, then try to source it after without checking if it was deleted?

Well in my case it isn't deleted anyway.

trusktr commented 4 years ago

If I add a line so I have

echo "$_SETUP_TMP"
. "$_SETUP_TMP"

I see

# prepend folders of workspaces to environment variables
export CMAKE_PREFIX_PATH="/opt/ros/melodic"
export LD_LIBRARY_PATH="/opt/ros/melodic/lib"
export PATH="/opt/ros/melodic/bin:$PATH"
export PKG_CONFIG_PATH="/opt/ros/melodic/lib/pkgconfig"
export PYTHONPATH="/opt/ros/melodic/lib/python3.8/site-packages"
# found environment hooks in workspaces
export _CATKIN_ENVIRONMENT_HOOKS_COUNT="9"
export _CATKIN_ENVIRONMENT_HOOKS_0="/opt/ros/melodic/etc/catkin/profile.d/1.ros_distro.sh"
export _CATKIN_ENVIRONMENT_HOOKS_0_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_1="/opt/ros/melodic/etc/catkin/profile.d/1.ros_etc_dir.sh"
export _CATKIN_ENVIRONMENT_HOOKS_1_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_2="/opt/ros/melodic/etc/catkin/profile.d/1.ros_package_path.sh"
export _CATKIN_ENVIRONMENT_HOOKS_2_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_3="/opt/ros/melodic/etc/catkin/profile.d/1.ros_python_version.sh"
export _CATKIN_ENVIRONMENT_HOOKS_3_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_4="/opt/ros/melodic/etc/catkin/profile.d/1.ros_version.sh"
export _CATKIN_ENVIRONMENT_HOOKS_4_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_5="/opt/ros/melodic/etc/catkin/profile.d/10.rosbuild.sh"
export _CATKIN_ENVIRONMENT_HOOKS_5_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_6="/opt/ros/melodic/etc/catkin/profile.d/10.roslaunch.sh"
export _CATKIN_ENVIRONMENT_HOOKS_6_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_7="/opt/ros/melodic/etc/catkin/profile.d/99.roslisp.sh"
export _CATKIN_ENVIRONMENT_HOOKS_7_WORKSPACE="/opt/ros/melodic"
export _CATKIN_ENVIRONMENT_HOOKS_8="/opt/ros/melodic/etc/catkin/profile.d/15.rosbash.zsh"
export _CATKIN_ENVIRONMENT_HOOKS_8_WORKSPACE="/opt/ros/melodic"

right before the error happens.

any idea what pwd:82: too many arguments means?

dirk-thomas commented 4 years ago

Why would it try to rm -rf the file, then try to source it after without checking if it was deleted?

Sorry, I have no idea what you are referring to.

I see

The content of the file looks correct. One note though: Melodic doesn't officially support Python 3 - only the newer distro Noetic does.

any idea what pwd:82: too many arguments means?

The shell is probably miinterpreting some part and as a result the number of arguments of e.g. the while loop condition is incorrect.

I can only suggest to debug each individual step of the script (e.g. by adding echo statement) to figure out what goes wrong.

I tried sourcing setup.sh but it results in an error:

Another note: when using zsh you should source the setup.zsh file - not the setup.sh file.

trusktr commented 4 years ago

Why would it try to rm -rf the file, then try to source it after without checking if it was deleted?

Sorry, I have no idea what you are referring to.

Above the line where the error happens (the error happens on the line with . "$_SETUP_TMP"), there's conditional expression that possibly deletes the temp file before the line that sources it will run. Seems like a potential problem, but in my case nothing to do with my issue.

EDIT: Oooh, the return 1 makes it exit the script. I overlooked that. I don't work in Bash often enough; my mind wasn't thinking about it.

Melodic doesn't officially support Python 3 - only the newer distro Noetic does.

So far no issues. Manjaro Linux (Arch Linux) comes with Python 3 by default. But I had to install some stuff manually using the pip2 command (for Python 2) before I was able to successfully install the set of ros-melodic-* packages that I need from AUR. Not sure if that Python 3 line you pointed out will have any issues, but so far things are working fine if I source setup.sh in Bash instead of ZSH.

I tried sourcing setup.sh but it results in an error:

Another note: when using zsh you should source the setup.zsh file - not the setup.sh file.

I figured to try both (setup.zsh sources setup.sh anyway). Turns out I get the same error either way. I'll just source setup.zsh though. :+1:

trusktr commented 4 years ago

Thanks for the guidance!

I just don't see it: I'm not experienced enough to tell why sourcing that temp file with . "$_SETUP_TMP" results in pwd:82: too many arguments. The content of the file looks fine, just some export statements. The file name inside of $_SETUP_TMP looks fine, nothing obvious there.

I figure the first error needs to be solved before looking at the second error (which may be caused by the first).

trusktr commented 4 years ago

I tried removing the rm -f "$_SETUP_TMP" line, so that I could then try to source the temp file. I had no issue running source /tmp/setup.sh.SyFwnfWRnm from my zsh shell, for example.

EDIT: Oooooh! source works, but . doesn't. For some reason, . is aliased to pwd. Looks like an issue with my Zsh config! All works if I remove that. Yaay. :tada: