Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zessx opened this issue Sep 13, 2022 · 3 comments
Closed

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

zessx opened this issue Sep 13, 2022 · 3 comments

Comments

@zessx
Copy link
Contributor

zessx commented Sep 13, 2022

Fatal Error

Exclude definitions from 190d93d 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
Copy link
Contributor Author

zessx commented Sep 13, 2022

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:

def expand_ignore_strings
expanded_ignore_strings = []
exclude_type = 'Name'
exclude_type = @options['sync_excludes_type'] unless @options['sync_excludes_type'].nil?
unless @options['sync_excludes'].nil?
expanded_ignore_strings = @options['sync_excludes'].append(Environment.default_ignores).flatten!.map do |pattern|
ignore_string = if exclude_type == 'none'
# the ignore type like Name / Path are part of the pattern
pattern.to_s
else
"#{exclude_type} #{pattern}"
end
"-ignore='#{ignore_string}'"
end
end
expanded_ignore_strings
end

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

EugenMayer pushed a commit that referenced this issue Sep 13, 2022
We cannot rely on `sync_excludes_type` for default ignores, at the user can and will override it for his needs.

Ref: #819
@EugenMayer
Copy link
Owner

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

@yosephsa
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants