3
$\begingroup$

Running ROS melodic on Ubuntu 18.04 and I keep getting this error.

$ roslaunch arm robot_spawn.launch

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

sudo apt install python-roslaunch

I was able to launch prior to this but decided to add another node though. When I try to reinstall it, I get a recursive errors like in this question. Anyway, I checked the solution provided in the question link that says that I need ros-melodic-launch and not python-roslaunch so I go ahead and try to source melodic's setup.bash but I already had

source /opt/ros/kinetic/setup.bash in my .bashrc.

Upon further digging I find another question. I have checked the logs of apt in /var/log/apt/history.log and can confirm that I have it.

$\endgroup$
2
  • $\begingroup$ Not exactly sure what is going on since adding another ros node shouldn't have anything to do with "roslaunch" aside frome launching your launch files? Have you sourced your "dev/setup.bash"? Have you recently installed an IDE that could potentially mess up your your paths?: "Anaconda" for instance It could be a lot of things. Have you tried re-installing ROS-Melodic? $\endgroup$
    – Spaceman
    Apr 10, 2020 at 13:43
  • $\begingroup$ yes, I have sourced bash and devel/setup.bash. I don't have an IDE. Running this on a VM so not enough space to add more than the required amount. $\endgroup$ Apr 10, 2020 at 16:49

2 Answers 2

5
$\begingroup$

Even though you have added source /opt/ros/kinetic/setup.bash to your .bashrc, the fact you get a "command not found" error indicates that somehow Bash can't find the roslaunch executable. To double-check your configuration, run the following command:

$ echo $PATH

If your environment is correctly configured to run ROS Kinetic, you should see an output of the form:

/opt/ros/kinetic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Notice that the first entry in the colon-separated list above is /opt/ros/kinetic/bin; if that's not the case in your system, that's probably the cause of the issue.

Even if the apt logs say roslaunch was installed, it's better to double-check whether it really is anywhere to be found. Search for the executable file using the command below:

$ sudo find / -name roslaunch

You should see the following output:

/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch
/opt/ros/kinetic/share/roslaunch
/opt/ros/kinetic/bin/roslaunch

If that's not the case, then roslaunch is not (correctly) installed. Otherwise, you might also check whether executable permissions are set for good measure:

$ ls -l /opt/ros/kinetic/bin/roslaunch
-rwxr-xr-x 1 root root 1657 Oct  8  2019 /opt/ros/kinetic/bin/roslaunch

Check whether the x flags are present in the output.

Generally speaking, (re)installing packages should be your last resort when dealing with environment issues. It's all too easy to run into conflicts and wreck your system to a degree that you might as well rebuild it from scratch. It's better to first try and determine what the problem is to begin with, before rushing into attempts at a solution.

If you installed the ros-kinetic-desktop-full meta-package then you should already have everything needed to run roslaunch; in any case, that certainly wouldn't have changed because you added another node to your project, either as sources in your workspace or by installing a binary package.

All that said, if roslaunch isn't found in your environment or you can't otherwise determine why calling it doesn't work, you might want to try reinstalling the whole ROS setup:

$ sudo apt purge ros-kinetic-desktop-full # or whatever meta-package you used
$ sudo apt autoremove
$ sudo apt install ros-kinetic-desktop-full

But I personally think the best approach is to cut your losses and reinstall the system from scratch, then if you get the same issue again try to determine the cause before (re)installing anything.

$\endgroup$
1
  • 1
    $\begingroup$ I wish I had seen the answer sooner then I would have proceeded with learning more about the system. I had eventually decided to reinstall the system from scratch and I didn't get issues. I can confirm at the very least that your best approach works. $\endgroup$ Apr 11, 2020 at 16:11
2
$\begingroup$

You may also just try running

sudo apt install ros-<your-distribution>-roslaunch

I was repeatedly running

sudo apt install python3-roslaunch

Which was installing roslaunch into python installation path and thus on running roscore, roslaunch was missing in

/opt/ros/<ros-distro>/share/ros
/opt/ros/<ros-distro>/share
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.