@@ -2,6 +2,7 @@ package manager
22
33import (
44 "context"
5+ "errors"
56 "os"
67 "os/exec"
78 "path/filepath"
@@ -13,6 +14,7 @@ import (
1314 "github.com/docker/cli/cli-plugins/metadata"
1415 "github.com/docker/cli/cli/config"
1516 "github.com/docker/cli/cli/config/configfile"
17+ "github.com/docker/cli/cli/debug"
1618 "github.com/fvbommel/sortorder"
1719 "github.com/spf13/cobra"
1820 "golang.org/x/sync/errgroup"
@@ -74,9 +76,17 @@ func addPluginCandidatesFromDir(res map[string][]string, d string) {
7476 return
7577 }
7678 for _ , dentry := range dentries {
77- switch dentry .Type () & os .ModeType { //nolint:exhaustive,nolintlint // no need to include all possible file-modes in this list
78- case 0 , os .ModeSymlink :
79- // Regular file or symlink, keep going
79+ switch mode := dentry .Type () & os .ModeType ; mode { //nolint:exhaustive,nolintlint // no need to include all possible file-modes in this list
80+ case os .ModeSymlink :
81+ if ! debug .IsEnabled () {
82+ // Skip broken symlinks unless debug is enabled. With debug
83+ // enabled, this will print a warning in "docker info".
84+ if _ , err := os .Stat (filepath .Join (d , dentry .Name ())); errors .Is (err , os .ErrNotExist ) {
85+ continue
86+ }
87+ }
88+ case 0 :
89+ // Regular file, keep going
8090 default :
8191 // Something else, ignore.
8292 continue
0 commit comments