diff --git a/cmd/coder/sync.go b/cmd/coder/sync.go index b28afd08..d5b4d4bb 100644 --- a/cmd/coder/sync.go +++ b/cmd/coder/sync.go @@ -1,6 +1,7 @@ package main import ( + "errors" "os" "path/filepath" "strings" @@ -28,6 +29,9 @@ func (cmd *syncCmd) RegisterFlags(fl *pflag.FlagSet) { fl.BoolVarP(&cmd.init, "init", "i", false, "do inititial transfer and exit") } +// See https://lxadm.com/Rsync_exit_codes#List_of_standard_rsync_exit_codes. +var NoRsync = errors.New("rsync: exit status 2") + func (cmd *syncCmd) Run(fl *pflag.FlagSet) { var ( local = fl.Arg(0) @@ -49,7 +53,7 @@ func (cmd *syncCmd) Run(fl *pflag.FlagSet) { remoteTokens := strings.SplitN(remote, ":", 2) if len(remoteTokens) != 2 { - flog.Fatal("remote misformmated") + flog.Fatal("remote misformatted") } var ( envName = remoteTokens[0] @@ -73,5 +77,10 @@ func (cmd *syncCmd) Run(fl *pflag.FlagSet) { for err == nil || err == sync.ErrRestartSync { err = s.Run() } - flog.Fatal("sync: %v", err) + + if err == NoRsync { + flog.Fatal("no compatible rsync present on remote machine") + } else { + flog.Fatal("sync: %v", err) + } } diff --git a/internal/sync/sync.go b/internal/sync/sync.go index 5c695260..2696ba1c 100644 --- a/internal/sync/sync.go +++ b/internal/sync/sync.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "os" "os/exec" "path" @@ -56,7 +57,7 @@ func (s Sync) syncPaths(delete bool, local, remote string) error { // good in general for codebases. cmd := exec.Command("rsync", args...) cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr + cmd.Stderr = ioutil.Discard cmd.Stdin = os.Stdin err := cmd.Run() if err != nil { @@ -248,7 +249,6 @@ func (s Sync) Run() error { return nil } - flog.Info("watching %s for changes", s.LocalDir) var droppedEvents uint64