Ask Your Question
1

Ros commands no longer working after source catkin_ws/devel/setup.bash

asked 2020-04-13 05:04:18 -0600

sverre gravatar image

Hi! One day I was suddenly not able to run my ros projects anymore. When I source /opt/ros/melodic/setup.bash the ros commands become available, such as catkin_make. But when I then try to source ~/scout/catkin_ws/devel/setup.bash such that I can run my own project files, the ros commands are no longer working. When I type for example catkin_make I get the following error:

Command 'catkin_make' not found, but can be installed with:

sudo apt install catkin

If I now re-run source /opt/ros/melodic/setup.bash the ros commands are working again, such as cakin_make. But I am not able to run any of my projects. Double tab-ing after typing rosrun does not show any of my projects, they do not autocomplete, and if I try to run them I get the warning '[rospack] Error: package "name of package" not found'. (where the name of my package is shown instead of "name of package").

It seems like to me that devel/setup.bash is malfunctioning and somehow counteracting melodic/setup.bash without doing what it is supposed to. Everything was working yesterday morning, and then it suddenly stopped working.

Im running on Ubuntu 18.04.4, ros melodic, and have installed gazebo9 if that is relevant. I normally run source from .bashrc, but I removed them in this test and ran them manually instead.

Any help in debugging this problem is highly appreciated! If there is some info that is missing please tell me, as I don't understand the problem and since I'm quite new to ROS I don't really know what's important and where to look...

Thank you in advance :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-04-13 07:12:14 -0600

hashirzahir gravatar image

Hi. There are 2 ways to solve this issue. You can place your source /opt/ros/melodic/setup.bash in your bashrc file and delete the build and devel folders of your catkin workspace and try rebuilding your workspace with catkin_make. If for some strange reason this doesnt work (it really should), you can utilize the --extend parameter of the source command to source more than 1 file. The source command generally overwrites one another in the sense that if you have 2 separate cakin workspaces A and B, if you perform source devel/setup.bash in workspace A and then perform source devel/setup.bash in workspace B, the second command will override the first command and the packages in workspace A will not be available to you.

To overcome this, in workspace A, perform source devel/setup.bash as usual but after this, going into workspace B ensure to perform source devel/setup.bash --extend and now packages from both workspaces will be enabled. In a similar light, perhaps you could try source /opt/ros/melodic/setup.bash and then source devel/setup.bash --extend in your workspace. But solution 1 should also work for you.

Hope that helps.

edit flag offensive delete link more

Comments

Thanks a lot! :D Deleting the build and devil folders worked :) When I ran catkin_make I got en error that it could not locate one of the headers that were generated by actionlib (even though it was there), the error did not show up the second time I built. Just in case someone experiences something similar

sverre gravatar image sverre  ( 2020-04-13 08:25:43 -0600 )edit

A follow-up question since only one source command can be run at once. Should then only the catkin_ws/devel/setup.bash be sourced in .bashrc, or only /opt/ros/melodic/setup.bash? I guess the first since that one is required to be able to see your project files? Does this setup include the things melodic setup does?

sverre gravatar image sverre  ( 2020-04-13 08:31:01 -0600 )edit
1

It is good practice to only keep the /opt/ros/melodic/setup.bash in the bashrc. Workspace sources should be sourced when necessary in the terminal. The --extend option is more for getting the packages from 2 local catkin workspaces on your computer. This is generally done to avoid any strange behaviour that may happen if there are conflicting package names or types in your various local workspaces. But if you only have 1 local catkin workspace on your computer, it is also okay to put your catkin_ws/devel/setup.bash in the bashrc for added speed. But what I tend to do is to add an alias like alias source_ws_a=source ~/a_ws/devel/setup.bash so that it is quick for me to source the appropriate packages.

hashirzahir gravatar image hashirzahir  ( 2020-04-13 10:07:03 -0600 )edit

so this happens to me every time I restart my machine, so does that really mean I'm supposed to be deleting devel and build whennever I restart my machine? What is the permanent fix? I looked at the code devel/setup.sh code and it seems to just be blanking out a bunch of params which is probably why catkin_make doesn't work. Should I just be directly setting the ROS_PACKAGE_PATH to include the workspace/src as well? I think that makes the package building work. and if I put the catkin_ws/devel/setup.bash in my bashrc it blanks everything out like the OPs original message

Geronimo gravatar image Geronimo  ( 2021-09-30 12:56:31 -0600 )edit

Manually setting ROS_PACKAGE_PATH is not needed. Cleaning out your workspace is not needed.

If you can't get the normal workflow to work, something is setup incorrectly. You should try to figure out what, instead of addressing the symptoms.

Post a new question, don't post additional questions under questions with answers from over a year go.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-30 13:18:25 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-13 05:04:18 -0600

Seen: 2,194 times

Last updated: Apr 13 '20