bcpierce00 / unison

Unison file synchronizer
GNU General Public License v3.0
3.98k stars 227 forks source link

Suggestion: use entr for fs-montior #76

Closed chengguangnan closed 7 years ago

chengguangnan commented 7 years ago

Hi, I tried to use -repeat watch but had problems to run it on macOS.

First of all, /usr/bin/python on macOS is python 2.7, but unison would still picked up ~/anaconda3/bin/python to run the scripts, which is is python 3 and there were syntax errors.

Maybe we could somehow integrate http://entrproject.org/ which does fs-montior? It might be more convenient, eg:

echo Documents/path/ | entr -d unison default

echo Documents/path/\nDocuments/path_2/ | entr -d unison default

alkuzad commented 7 years ago

by python you meant legacy old python monitor ? It's obsolete now and unison uses it's own monitor written in OCaml (native Unison language). Older python version was using intervals to monitor files and "-repeat watch" uses inotify library. Update your unison then.

chengguangnan commented 7 years ago

I'm using unison 2.50.0 and it's still using fsmonitor.py.

I built it from the git master branch. When I run unison default --repeat watch there is an error about fsmonitor in the log:

Unison 2.50.0 (ocaml 4.04.1): Contacting server...
Connected [//-> //]
Looking for changes
file  File "/usr/local/bin/fsmonitor.py", line 326
    except os.error, msg:
                   ^
SyntaxError: invalid syntax
 (most recent call last):
  File "/usr/local/bin/fsmonitor.py", line 307, in <module>
    from FSEvents import *
chengguangnan commented 7 years ago

@alkuzad @bcpierce00 where is this new OCaml monitor?

unison 2.50.0 still uses the old python monitor.

alkuzad commented 7 years ago

@chengguangnan new: https://github.com/bcpierce00/unison/blob/master/src/fswatch.ml + https://github.com/bcpierce00/unison/tree/master/src/fsmonitor old: https://github.com/bcpierce00/unison/blob/master/src/fswatchold.ml

I use released version not trunk so i can not verify this.

>unison -version

unison version 2.48.3

chengguangnan commented 7 years ago

But I had this error on mac and ubuntu. See error below.

~ ➤ unison default -repeat watch
Contacting server...
Connected [//MacBook-Pro.local//Users/chengguangnan -> //PowerEdge//home/chengguangnan]
Looking for changes
| workspace...abc.htmlTraceback (most recent call last):
  File "/usr/local/bin/fsmonitor.py", line 307, in <module>
    from FSEvents import *
ImportError: No module named 'FSEvents'
| workspace...abc.html  File "/usr/local/bin/fsmonitor.py", line 326
    except os.error, msg:
                   ^
SyntaxError: invalid syntax
  Waiting for changes from server
Reconciling changes
Nothing to do: replicas have not changed since last sync.
^CTerminated!
Killed by signal 2.