9

I use Unison to sync website projects across my machines, in one of my machines I would like to avoid sycning (both ways)some folders contained with in the folders I watch:

/vendor
/node_modules
/storage/debugbar
/staroge/framework

This is the profile I use to .prf file I use to execute the sync, you can see that the folders are there in the ignore path lines.

# Roots of the synchronization
root = /Volumes/Data HD
root = ssh://Server//volume1/My Files

# Paths
path = Sites

# Some regexps specifying names and paths to ignore
ignore = Name */@eaDir
ignore = Name */_notes
ignore = Name .DS_Store
ignore = Name SyncToy_*.dat
ignore = Path */Archives
ignore = Path */tools
ignore = Name *.sublime*

# Ignore laravel composer and npm folders
ignore = Path {Sites/CRMJobs/node_modules}
ignore = Path {Sites/Loot/node_modules}
ignore = Path {Sites/Pompous/node_modules}
ignore = Path */vendor
ignore = Path */node_modules
ignore = Path */storage/debugbar
ignore = Path */storage/framework

log = true
times = true
auto = true

You can see that in some cases I've even explicitly mentioned full patches to ignore yet they are still synchronised.

Can someone tell me what I am doing wrong?

5
  • The only thing I could think of right now is: what is the topology you are using to synchronize across multiple machines? I am asking because only the .prf file on the machine initiating the connection is taken into account. Could it be the case that you're initiating the sync from a machine that doesn't have the correct .prf file? By the way, you may want to consider synchronizing those .prf files, too!
    – Edward
    Nov 30, 2017 at 6:35
  • But why did you cross-post to SU and SO at the same time?
    – Edward
    Nov 30, 2017 at 6:35
  • I posted on both in an effort to get an answer quickly, will remove the SO version. I am using the star topology to sync. I don't think having the same .prf file is the issue as the central machine usually receives all data under my Sites directory but depending on which machine I'm using I'll only sync certain subdirectories.
    – Imran
    Nov 30, 2017 at 13:17
  • could it be that the machine where you execute unison from doesn't have a .prf file with the ignore lines?
    – Edward
    Dec 1, 2017 at 10:55
  • ignore = Name .DS_Store works here. Could it be that the directive is overrridden by some other directive? Have you tried to isolate it to only this directive?
    – ivvi
    May 2, 2023 at 17:21

2 Answers 2

12

See this bit on Path Specification in the Unison manual. Instead of Path you should use Name.

ignore = Name vendor
ignore = Name node_modules
ignore = Name storage/debugbar
ignore = Name storage/framework
1

I used one big ignore regex to do this because all other approaches didn't work. If unison would support negative lookaheads, this would have been so much simple, but I had to use an emulation through negative character classes as described here:

https://clusterise.com/articles/regex-negative-lookahead/

If I want only 2 subfolders e.g. "abc" and "def" to be included, I use something like the following:

Regex ^([^ad].*|a[^b].*|ab[^c].*|d[^e].*|de[^f].*)

which kind emulates the negative lookahead ^(?!abc|def)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .