Ask Your Question

How to specify launch file path in snap creation?

asked 2020-10-27 11:23:13 -0600

Py gravatar image

I am having trouble getting a snap of my ROS package to work correctly. After creating the snapcraft.yaml file, successfully generating the snap and installing it, I get this message when trying to run the ROS package:

This part is missing libraries that cannot be satisfied with any available stage-packages known to snapcraft:
These dependencies can be satisfied via additional parts or content sharing. Consider validating configured filesets if this dependency was built.
The command 'roslaunch' for 'roslaunch ROS_PACKAGE launch_file.launch' was resolved to 'opt/ros/melodic/bin/roslaunch'.
The command 'roslaunch ROS_PACKAGE launch_file.launch' has been changed to 'opt/ros/melodic/bin/roslaunch ROS_PACKAGE launch_file.launch'.
Snapping |                                                                                                                                                                                                          
Snapped snap-name_0.1_amd64.snap
(venv) user@computer:~/catkin_ws/src/ros_package$ sudo snap install --devmode --dangerous *.snap
snap-name 0.1 installed
(venv) user@computer:~/catkin_ws/src/ros_package$ snap-name 
RLException: [launch_file.launch] is neither a launch file in package [contamination_mapping] nor is [contamination_mapping] a launch file name
The traceback for the exception was written to the log file

Could anyone suggest what might have gone wrong in the process?

edit retag flag offensive close merge delete


I see this type of error most often as a result of missing installation rules. Double check that you're actually installing that launch file in the CMakeLists.txt.

kyrofa gravatar image kyrofa  ( 2020-10-27 11:28:29 -0600 )edit

Thanks very much! I have this in CMakeLists.txt. Is this right?

install(DIRECTORY launch/
Py gravatar image Py  ( 2020-10-27 11:34:03 -0600 )edit

Also, I've just seen the following in the messages I get at the end of snap creation: No packages found in source space. Does this offer any clues?

Py gravatar image Py  ( 2020-10-27 11:38:09 -0600 )edit

Yeah it does. When you're building a snap, snapcraft needs to operate on a workspace. That message makes me think maybe you're trying to get it to build a single package, is that true? You need to point it at either a workspace or a rosinstall file (and it'll create a workspace before merging that rosinstall file in).

kyrofa gravatar image kyrofa  ( 2020-10-28 14:12:35 -0600 )edit

Yes that's right I was trying to build a single package. What folder should the snapcraft.yaml and .rosinstall file be in? For the .rosinstall file, would this just contain the following? - git: {local-name: my_ros_package, uri: '', version: master}

Py gravatar image Py  ( 2020-10-29 02:19:21 -0600 )edit

Also, on the snap tutorial here, I seemed to think that the snapcraft.yaml was just referencing the ROS package Github repository and I didn't need the whole local workspace. Maybe I'm misunderstanding?

Py gravatar image Py  ( 2020-10-29 03:55:23 -0600 )edit

Yeah the snap tutorial cheats a little. It pulls down that github repo, but then it tells catkin that instead of the source-space being the default src subdirectory, it's the roscpp_tutorials subdirectory, and thus catkin happily proceeds as if it were operating on a workspace. You can do a similar thing if you like that better than a rosinstall file, but I'll give more rosinstall details in my answer shortly as its a bit more generically useful (doesn't require your repo to be structured in any particular way).

kyrofa gravatar image kyrofa  ( 2020-10-29 09:51:54 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-29 12:29:34 -0600

kyrofa gravatar image

updated 2020-10-29 12:30:03 -0600

Note that snapcraft currently only supports building workspaces into snaps, not individual ROS packages. This is a known shortcoming and is slated to be fixed this cycle. The easiest workaround for this is to use a rosinstall file, which will cause snapcraft to create a workspace on your behalf instead of requiring you to do it.

To describe how this is done, I'll alter the snap tutorial you're using to use a rosinstall file. First of all, let's create our snapcraft yaml:

$ mkdir ~/my-snap
$ cd ~/my-snap
$ snapcraft init
Created snap/snapcraft.yaml.
Go to for more information about the snapcraft.yaml format.

Edit the snap/snapcraft.yaml and make it look like this:

name: ros-talker-listener
version: '0.1'
summary: ROS Talker/Listener Example
description: |
  This example launches a ROS talker and listener.

confinement: devmode
base: core18

    plugin: catkin
    source: .
    rosinstall-files: [ros_tutorials.rosinstall]
    catkin-packages: [roscpp_tutorials]
    build-packages: [lsb-release]  # I needed this in LXD, you may not

    command: roslaunch roscpp_tutorials talker_listener.launch

Note the use of rosinstall-files. Let's create a ros_tutorials.rosinstall file alongside the snap/ directory:

$ touch ~/my-snap/ros_tutorials.rosinstall

Make that file look like the following:

- git: {local-name: ros_tutorials, uri: '', version: melodic-devel}

Save, and build the snap. Note the installation of wstool and the workspace merging happening before fetching dependencies and whatnot:

$ snapcraft
Pulling ros-tutorials 
Installing wstool...
Initializing workspace (if necessary)...
Merging /root/parts/ros-tutorials/src/ros_tutorials.rosinstall
Updating workspace...
Installing apt dependencies...
Building ros-tutorials
Snapped ros-talker-listener-test_0.1_amd64.snap
edit flag offensive delete link more

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


Asked: 2020-10-27 11:23:13 -0600

Seen: 22 times

Last updated: Oct 29