2

unison-jz works well on a bash command-line but not inside a script. It seems that inside the script, it falls back to the regular unison command. Can someone tell me how to use unison-jz inside a bash script?


I had the unison version conflict that is described in #583058 and the proposed solution for ubuntu works fine on an interactive shell.

However, I want to do the same from inside a bash script:

#!/bin/bash
unison profile_name -sshargs '-i ~/.ssh/privatekey'

This is a MWE version of the script.sh (in reality the script is more copmlex, but I checked this MWE and it shows the same faulty behaviour). When I invoke this script from the same command line as before (but also from another shell), it seems that inside the script, the regular unison version is used instead of the snapped unison-jz (which is used when invoking from the interactive shell). Hence, the syncing fails with the same Fatal error as before, saying "This can happen because you have different versions of Unison installed on the client and server machines", which I had fixed with the above approached.

How can I make the shell script use the snapped unison-jz version instead of unison?

Both client and server use bash shell on ubuntu (client: 20.04, server: 18.04).


What I've done on the command-line:

  1. Install snap:

    sudo snap install --devmode unison-jz

  2. Add this line to my unison profile file:

    servercmd = /snap/bin/unison-jz.unison -ui text

  3. Comment out line 19 in /etc/ssh/ssh_config so that is looks like

    # Include /etc/ssh/ssh_config.d/*.conf

  4. Execute unison:

    unison profile_name -sshargs '-i ~/.ssh/privatekey'

This works fine from an interactive bash shell.

dani
  • 21
  • 2
  • Have you tried running the path explicitly in the script? e.g. ``/snap/bin/unison-jz.unison -ui text profile_name -sshargs '-i ~/.ssh/privatekey'``? – WesH Mar 22 '22 at 16:24
  • If I do that, it tells me that `/home/username/snap/unison-jz/19/.unison//home/username/.unison/profile_name.prf`, even if I explicitly give it the profile path as `/home/username/.unison/profile_name.prf` – dani Apr 12 '22 at 13:13
  • I meant to use the command explicit but not ``profile_name``. A unison quirk requires that be installed in the correct dir and typed with no extension. I poked at my problems more since I made this comment. The snap package requires you do everything inside of their walled garden, making issues like this pop up. e.g., don't use default ``.unison`` paths. I ended up compiling and installing from ``opam`` rather than deal with the snap package problems. I recommend it. – WesH Apr 13 '22 at 14:58

0 Answers0