ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Why does sourcing my workspace cause the error "catkin_make: command not found"?

asked 2017-09-25 20:53:23 -0600

M@t gravatar image

updated 2017-09-26 18:52:08 -0600

I've been messing around with my catkin workspace in an attempt to get QtCreator working with ROS (Indigo Igloo, Ubuntu 14.04, QtCreator 5.9.1), and somewhere along the way I've messed up something important. So now, if I run:

$ source /opt/ros/indigo/setup.bash
$ cd repo/workspace/
$ catkin_make

Everything builds properly, but if I source my workspace between sourcing the ROS distro and running catkin_make then the command fails. I.e. if I run:

$ source /opt/ros/indigo/setup.bash
$ source /home/user/repo/workspace/devel/setup.bash
$ cd repo/workspace/
$ catkin_make

Then I get the following error

catkin_make: command not found

Does anyone know why this is the case? Obviously, there is something wrong with my setup but I don't understand enough about CMake to figure it out. I'm also not sure what diagnostic info I need to post here to help others, so if there is something specific about my setup that I should post here, let me know. Thanks in advance for any help or advice.


Updates

As per @psammut's comments, I tried copying all the source code into a new workspace. I can run catkin_make in the new workspace just fine, regardless of whether it is sourced or not. But the minute I source my original workspace, catkin_make throws an error in either workspace.

As per @ahendrix's answer. If I build my workspace with Qt (or try to since it fails when Qt tries) and the Qt CMAKE_PREFIX_PATH is set to "/home/user/Qt/5.9.1/gcc_64", my PATH variable looks like this before and after sourcing the workspace:

Before:

/opt/ros/indigo/bin:/home/user/.nvm/versions/...

After:

/home/user/Qt/5.9.1/gcc_64/bin:/home/user/.nvm/versions/...
edit retag flag offensive close merge delete

Comments

Hate to be that guy, but if you installed ros from the binaries, have you tried just uninstalling and re-installing?

psammut gravatar image psammut  ( 2017-09-25 21:23:15 -0600 )edit
1

Also, another suggestion, if you didn't touch the ros files and re-installing is not the cause of the problem, simply make a new workspace and just transfer over the source files to it. Then rebuild and try again.

psammut gravatar image psammut  ( 2017-09-25 21:26:06 -0600 )edit

No worries, re-installing is definitely an option (done it before). But I'd like to leave it as a last resort, if only because I'll (hopefully) learn something if I can solve the underlying problem. I'll try your suggestion of a new workspace and report back.

M@t gravatar image M@t  ( 2017-09-25 21:49:31 -0600 )edit

So... HOW IN THE WORLD DO WE PROPERLY SET UP QT 5 LIBS!?!?!

DrewHamilton gravatar image DrewHamilton  ( 2020-12-19 13:59:07 -0600 )edit

@DrewHamilton You should create a new question and reference this one. That'll give your issue more visibility

jayess gravatar image jayess  ( 2020-12-20 00:08:18 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-09-25 23:36:26 -0600

ahendrix gravatar image

It seems like your workspace is setting the PATH environment variable incorrectly. Sourcing one workspace overrides and previous workspace or other setup.bash, so it doesn't matter if you've sourced the setup.bash for the system install of ROS or not.

I would look at the PATH after you've sourced the setup.bash for your workspace, to see if it's including a path to a previous version of ROS or a workspace that's been deleted.

You can re-create the setup.bash in your workspace by deleting the devel folder, sourcing your system install and rebuilding the workspace:

cd /home/user/repo/workspace
rm -rf build devel
source /opt/ros/include/setup.bash
catkin_make
edit flag offensive delete link more

Comments

Thanks @ahendrix, I've updated my question. So essentially, Qt messes up the workspace env variable, sourcing it messes up the PATH variable, so when I invoke catkin_make it can't find the command because the ROS directory is not longer in PATH? Is that an appropriate summary?

M@t gravatar image M@t  ( 2017-09-26 15:39:33 -0600 )edit

catkin clean also deletes devel file, so that fits with your solution.

M@t gravatar image M@t  ( 2017-09-26 15:40:36 -0600 )edit
1

answered 2017-09-25 22:49:51 -0600

M@t gravatar image

updated 2017-09-27 15:49:38 -0600

TL;DR

Run catkin clean in the affected workspace to clear the devel folder. Open a new terminal without the messed up PATH, source the ROS distro, run catkin_make.

Full Explanation

@ahendrix's answer is correct, this is a more detailed explanation of what went wrong and why. While messing with Qt, I had unintentionally changed the CMAKE_PREFIX_PATH.

As explained in the catkin workspace mechanics and catkin config docs, the CMAKE_PREFIX_PATH dictates how your workspace is chained and where catkin looks for dependencies. Somehow, I had changed CMAKE_PREFIX_PATH and then built the workspace using Qt, so that the erroneous CMAKE_PREFIX_PATH ended up as part of the workspaces' environment variables.

A workspace with the correct environment variables (use catkin config to see this) should look something like this:

Extending:          [cached] /opt/ros/indigo
Workspace:                   /home/user/repo/workspace

Where the ROS distribution has been sourced first (either using source or by editing your .bashrc file) and then extended by workspace.

Because I had (somehow) set CMAKE_PREFIX_PATH to the wrong file path, my workspace environment variables looked like this:

Extending:          [cached] /home/user/Qt/5.9.1/gcc_64
Workspace:                   /home/user/repo/workspace

Which is obviously wrong. Then, by sourcing this workspace again I was effectively overwriting my PATH with this erroneous file path, creating a PATH variable that didn't include the ROS distribution (i.e. included "/home/user/Qt..." instead of "/opt/ros/indigo"). catkin_make is actually a tool provided in your ROS distribution, and not a built-in command like catkin clean or config. So when invoking catkin_make, Ubuntu searched my PATH for the directory containing catkin_make, and because the necessary directory wasn't there, gave me the "command not found" error.

To fix this, run catkin clean in the affected workspace, which clears the workspace devel folder. Then build the workspace again using catkin_make in a new terminal, being careful to only source the ROS distribution first.

If there's anything wrong with my explanation or something I should add, please let me know. Thanks to @psammut and @ahendrix for pointing me in the right direction.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-09-25 20:53:23 -0600

Seen: 2,389 times

Last updated: Dec 19 '20