Executing a snap from within a snap package

I am trying to run the MuseScore snap from within my own Java snap package.
My code is as follows:

Runtime.getRuntime().exec("musescore.mscore " + file.getPath());

This generates the error: Exception - Cannot run program “musescore.mscore”: error = 2, No such file or directory.
I would be grateful for some advice as to whether this is possible and, if so, what would need to be done to make it work.

Hi there, that is currently no possible with the current design. The topic is covered and being discussed on How to confine a desktop shell


I wonder if xdg-open <filepath> works as some kind of proxy is done with this command?

IIRC xdg-open is filtered for protocols and will only open the default defined app for a mime type …

The problem is whether a snap application can define a mime type for itself, and, if it is set is it launch-able by another snap application?

Thus for Musescore as long as it’s file has a unique mime type it should be technically launch-able.

i think the re-write (userd ?) of the snapd-xdg-open tool we used to have was supposed to add more flexibility for exactly such use-cases but i dont think it does currently allow more than http/https/help protocols and does not hand over mime-types …

1 Like

I’ve tested it, it won’t.

The default Musescore file format is a ZIP archive(compressed) and an XML markup file(uncompressed), and thus if the file is opened from the other snap it will only launch File Roller and Gedit by default in Ubuntu desktop :frowning:

Although it’s not a direct solution to your problem, an alternative approach that you could take is to embed the Musescore snap in your snap. An an example of this is a part like this in your snap (demonstrating embedding Mosquitto):

    plugin: nil
    override-build: |
      snap download mosquitto
      unsquashfs mosquitto_*.snap
      cp squashfs-root/*.conf $SNAPCRAFT_PART_INSTALL/
      cp -r squashfs-root/lib $SNAPCRAFT_PART_INSTALL/
      cp -r squashfs-root/usr $SNAPCRAFT_PART_INSTALL/
      cp -r squashfs-root/snap/local $SNAPCRAFT_PART_INSTALL/

If Musescore is a dependency for your snap and there is no direct interface to Musescore, then this seems reasonable to me. You can just embed the parts of Musescore that you need.


What would you expect to happen if the musescore snap isn’t installed?

Hi chipaca,
I am checking for the existence of the musescore snap by:

if (new File("/snap/musescore").exists())

But, in any event, I should have realised my approach was not going to work as snaps are not allowed to access each other’s data by default as pointed out by jdstrand in call for testing MuseScore v 2.1.0.