Re: Problem with sync on an ARM Mac

"Stefan M. Moser" <[email protected]> Fri, 3 May 2024 07:45:07 +0800
Newsgroups gmane.network.unison.general
Message-ID <[email protected]>
Dear Christophe,

Very very likely you do have the issue that your laptop "changes name". This happens if you are originally not connected with your network and then get connected, or the connection changes (Wifi on->off->on, etc.), etc. In general, a laptop is mobile and thus keeps having new addresses depending on where you are.

I've been using Unison in a similar way to you, with the difference that I don't use an external disk to sync, but a server that I contact via ssh. I also always sync before I start working and after I have finished working, to make sure that I have always the up-to-date state on all of my machines I work on.

What you need to do is to give your computers a fixed "name". What that name is, doesn't matter. I have names for my computers anyway and simply use the same name also for unison. 

Now I know that there exists the unison preference "clientHostName" exactly for that purpose, but I haven't really understood how this works, particularly, as in your case the server and the client are the same machine. So you would have to make sure that the external SSD is the "server" and the computer is the client. But I do not understand how I can achieve this. 

***(That is actually a general question to the experts: how are the names "server" and "client" used in the context of unison? For example, if I use ssh to sync with a remote computer, is the remote computer the server or the client? And therefore, does the clientHostName preference fix the name of the computer unison is started by me or on the computer that is contacted from unison via ssh? And what happens if both roots are local?)***

I have solved the problem by setting the fixed name via UNISONLOCALHOSTNAME and do this in two places on EACH machine, using DIFFERENT names on each machine! In the example below I use "Arnold" as name --- pick anything you like.

1) For the shell: I'm using zsh, so I have the following line in my .zshrc:

export UNISONLOCALHOSTNAME="Arnold"

On 10.13 you might be using a different shell, and then the exact form of the command might look slightly different. For example, on a tcsh, it would be "setenv UNISONLOCALHOSTNAME Arnold".  

2) For the finder: Create a file "environment.plist" with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://urldefense.com/v3/__http://www.apple.com/DTDs/PropertyList-1.0.dtd__;!!IBzWLUs!W7Ui3mki9obMl6pWNjVoGS8QTZVbbP2voVItN75K5Me9K6hD6bXVuPlSqBbs9lNV4uDqtNXJ8aKS_7Qj1OCs-9KJxRQ$ ">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>my.startup</string>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/launchctl</string>
    <string>setenv</string>
    <string>UNISONLOCALHOSTNAME</string>
    <string>Arnold</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

(you notice the name "Arnold" again, replace it with your name of choice --- same one as in the .zshrc!!)

and copy this into /Library/LaunchDaemons/ and /Library/LaunchAgents/ and change owner of the file to root:wheel:

>sudo -s
>cp environment.plist /Library/LaunchDaemons/
>cp environment.plist /Library/LaunchAgents/
>chown root:wheel /Library/LaunchDaemons/environment.plist
>chown root:wheel /Library/LaunchAgents/environment.plist
>exit


Finally reboot the machine.

If you now start unison, it will once more complain that no archive file are found and you will have to recreate them again, but afterwards you should be fine.

Cheers,

Stefan


> On 3 May 2024, at 04:13, Christophe Leterrier <[email protected]> wrote:
> 
> Hi,
> 
> Thank you for your help. I just can't see how to use UNISONLOCALHOSTNAME for my laptop - how do I now what is the host name, how do I set it, and to what value? The paths I use to sync are both local, it's a really simple case:
> 
> # Travail Unison preferences file
> root = /Users/christo/Travail
> root = /Volumes/Slim/Unison
> 
> What can happen to something as simple as that? I tried to go to each root via the Go to Folder menu item in the Finder when the error happens, and both are perfectly fine and open their respective folder.
> 
> 
> On Thu, May 2, 2024 at 8:40 PM Tõivo Leedjärv <[email protected]> wrote:
> Could it be that the laptop changes the name automatically? See a
> recent thread in the archive:
> https://urldefense.com/v3/__https://groups.google.com/a/seas.upenn.edu/g/unison-users/c/B3iVo66Wi-w__;!!IBzWLUs!W7Ui3mki9obMl6pWNjVoGS8QTZVbbP2voVItN75K5Me9K6hD6bXVuPlSqBbs9lNV4uDqtNXJ8aKS_7Qj1OCsrBow9Yo$ 
> Basically, even if not doing a sync over the network, if the local
> hostname changes, it will cause the lookup of archive files to fail.
> If you don't know if the hostname changes, you can put this theory to
> test by including the "clientHostName" preference with a constant
> value to see if this helps or not.
> 
> On Thu, 2 May 2024 at 19:25, Christophe Leterrier
> <[email protected]> wrote:
> >
> > Hi, long time Unison user here on Mac and Windows. I have a setup for more than 10 years now to backup and sync my work computer. It goes like this:
> >
> > A whole "Work" folder from my desktop Mac (Intel iMac, drive is APFS SSD, MacOS 13.6.6) is synced to a folder on a 2 TB external SSD drive (formatted as APFS). It uses Unison 2.53.3 with ocaml 4.14.1
> > I then sync a subset of this folder (some subfolders etc.) from the external SSD drive to my laptop (MacBook Air M2, APFS SSD drive, MacOS 13.6.6) to keep with what I'm currently working on. It uses Unison 2.53.4 with ocaml 4.14.1.
> > I go from iMac to laptop and back using the external drive, syncing on each machine to update with what I've done on the other.
> >
> > No problem syncing between iMac and external drive, but when I try to sync between external drive and laptop, I often get the "No archive files were found for these roots" error. I have to delete the archives files in Library/Application Support/Unison, rescan the whole thing and then it accepts to sync the small changes. Then it works for ~24h before complaining about the missing archive files (even if I only worked on the laptop in between, meaning the external drive was synced with the laptop last, next day I sync again with the laptop, I get the error).
> >
> > How can I help get this problem solved? It's hard to keep using Unison if it entails a ~1h sync and rebuilding archives every time I sync with one of my two computers. I posted this on Unison Github and was pointed to this mailing list with the hint that "My Mac keeps changing paths" but I don't know what that means or how to avoid it?
> >
> > —
> >
> > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> 
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].


To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].