EugenMayer / docker-sync

Run your application at full speed while syncing your code for development, finally empowering you to utilize docker for development under OSX/Windows/*Linux
GNU General Public License v3.0
3.54k stars 289 forks source link

Fatal error with Unison because of wrong default exclude definitions #819

Closed zessx closed 2 years ago

zessx commented 2 years ago

Fatal Error

Exclude definitions from https://github.com/EugenMayer/docker-sync/commit/190d93d44bde47d5c7d9f11e2ef329223bfd1364 are not following the Unison format.

The following error now occurs at each start:

success  Unison server started
command  docker inspect --format='{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' wakeo_platform_sync
command  docker inspect --format='{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' wakeo_platform_sync
command  unison -ignore='Path .git' -ignore='Path tmp' -ignore='Path db/backups' -ignore='Path log' -ignore='Path vendor' -ignore='.docker-sync/daemon.log' -ignore='.docker-sync/daemon.pid' -ignore='.docker-sync/daemon.log' -ignore='.docker-sync/daemon.pid' -ignore='.docker-sync/daemon.log' -ignore='.docker-sync/daemon.pid' '/Users/samuel/Projects/wakeo_platform' -auto -batch -prefer '/Users/samuel/Projects/wakeo_platform' -copyonconflict socket://127.0.0.1:51367
  error  Error starting sync, exit code 7
message
message  Fatal error: Usage: unison [options]
        […]

         bad pattern:  .docker-sync/daemon.log
         A pattern must be introduced by one of the following keywords:
             Name, Path, BelowPath or Regex.

success  Starting Docker-Sync in the background

When the Unison strategy is used, the Environment.default_ignores values must be changed by prepending Path to each of them.

Docker Driver

No idea (using the native Docker Desktop app for macOS)

Sync strategy

unison

your docker-sync.yml

version: "2"
options:
  verbose: true
syncs:
  wakeo_platform_sync:
    src: .
    sync_excludes_type: none
    sync_excludes:
      - "Path .git"
      - "Path tmp"
      - "Path db/backups"
      - "Path log"
      - "Path vendor"
    sync_strategy: unison 
    sync_prefe: default 

OS

macOS Monterey 12.3

zessx commented 2 years ago

After a few tests, it works with the following settings:

version: "2"
options:
  verbose: true
syncs:
  wakeo_platform_sync:
    src: .
    sync_excludes_type: Path
    sync_excludes:
      - .git
      - tmp
      - db/backups
      - log
      - vendor
    sync_strategy: unison 
    sync_prefe: default 

It appears the sync_excludes_type is also used on the default_ignores values, which does make sense to me. If I understand this correctly, the purpose of sync_excludes_type is to simplify configuration (to not have to prepend Path Regex or Name on all excludes). But still, I am allowed to mix types, thanks to none:

    sync_excludes_type: none
    sync_excludes:
      - Path .git
      - Regex *\.log

Here is the related code portion: https://github.com/EugenMayer/docker-sync/blob/190d93d44bde47d5c7d9f11e2ef329223bfd1364/lib/docker-sync/sync_strategy/unison.rb#L98-L116

I think sync_excludes_type should be kept/used for user exclusions only. Default exclusions should be fully defined with their Unison prefix.

EugenMayer commented 2 years ago

thanks to #821 and #820 this will be fixed in 1.0.2 - thank you everyone for helping out

yosephsa commented 2 years ago

@EugenMayer & @zessx This is not completely fixed yet. That change needs to happen on native_osx sync strategy as it also uses the exclude_type Name and will throw the same error if set to none