My program cannot find another program that was packaged together


#1

Recently I’ve defined a snap package for our model-based testing tool. This tool comes with a command txsui which connects to a server process, which can be launched using another command txsserver. In turn txsserver launches another program, z3. All these binaries are packaged together:

  torxakis-bin:
    # See 'snapcraft plugins'
    plugin: dump
    source: .stack-work/install/x86_64-linux-nopie/lts-9.7/8.0.2/bin/
    stage-packages: []

  cvc4-bin:
    plugin: dump
    source: https://github.com/TorXakis/Dependencies/releases/download/cvc4_1.5/cvc4-1.5-x86_64-linux-opt.tar.gz

  z3-bin:
    plugin: dump
    source: https://github.com/TorXakis/Dependencies/releases/download/z3-4.5.1/z3-4.5.1.x64-ubuntu-14.04.tar.gz
    
apps:
  txsui:
    command: txsui
    plugs:
      - network
      - home
      - network-bind

  txsserver:
    command: txsserver
    plugs: 
      - network
      - home
      - network-bind

  z3:
    command: bin/z3
    plugs:
      - network
      - home
      - network-bind

  cvc4:
    command: cvc4-1.5-x86_64-linux-opt
    plugs:
      - network
      - home
      - network-bind

Where the the contents of .stack-work/install/x86_64-linux-nopie/lts-9.7/8.0.2/bin/ are listed below:

$ ls .stack-work/install/x86_64-linux-nopie/lts-9.7/8.0.2/bin/
txsserver  txsui

Now if I run txsserver it can find the z3 binary without a problem, but it I launch txsui, it cannot find the txsserver command (I get a “no such file or directory” error). I cannot explain the difference in behaviour (why txsserver can find z3 but txsui cannot find txsserver). Any help is greatly appreciated!


#2

As additional information, I recently requested an alias for torxakis.txsui and torxakis.txsserver. I don’t know whether that might be causing the issue…


#3

What happens when you run txsserver first? Looking at your code the torxakis.sh command normally spawns txsserver on a specific port before running txsui with the same port number.

Alternatively, your haskell code appears to be trying to start txsserver without specifying a path to locate the executable, which means the current PATH variable will be used to determine the file to run. As you are not using a wrapper script which changes the path then your program will not find your binary in $SNAP/txsserver because $SNAP won’t be included in the PATH.


#4

What happens when you run txsserver first? Looking at your code the torxakis.sh command normally spawns txsserver on a specific port before running txsui with the same port number.

If I run txsserver first then it works. Note that the snap I built does not include torxakis.sh (which was a quick and dirty hack).

Alternatively, your haskell code appears to be trying to start txsserver without specifying a path to locate the executable, which means the current PATH variable will be used to determine the file to run.

Yes, this is correct. So txsserver and z3 should be in the $PATH. What is strange is that z3 (which is also started without specifying the full path, just "z3") is found, but txsserver is not.

As you are not using a wrapper script which changes the path then your program will not find your binary in $SNAP/txsserver because $SNAP won’t be included in the PATH.

But why is z3 found? (when spawned by txsserver?). Also I would expect that all the executables declared under apps to be included in the $PATH directory. Won’t this otherwise require that all the package writers that require such functionality (i.e. executables in a snap calling other executables within the same snap) will have to write this boilerplate script?


#5

Anybody else might have any ideas on what might be going on here?