@@ -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"
@@ -57,9 +59,17 @@ func addPluginCandidatesFromDir(res map[string][]string, d string) {
5759 return
5860 }
5961 for _ , dentry := range dentries {
60- switch dentry .Type () & os .ModeType { //nolint:exhaustive,nolintlint // no need to include all possible file-modes in this list
61- case 0 , os .ModeSymlink :
62- // Regular file or symlink, keep going
62+ switch mode := dentry .Type () & os .ModeType ; mode { //nolint:exhaustive,nolintlint // no need to include all possible file-modes in this list
63+ case os .ModeSymlink :
64+ if ! debug .IsEnabled () {
65+ // Skip broken symlinks unless debug is enabled. With debug
66+ // enabled, this will print a warning in "docker info".
67+ if _ , err := os .Stat (filepath .Join (d , dentry .Name ())); errors .Is (err , os .ErrNotExist ) {
68+ continue
69+ }
70+ }
71+ case 0 :
72+ // Regular file, keep going
6373 default :
6474 // Something else, ignore.
6575 continue
0 commit comments