kubernetes/kubectl

"plugins list" command raises errors for non-existing dirs in $PATH

ahmetb opened this issue · 14 comments

It appears like kubectl plugins list explicitly prints errors for dirs that don't exist but added to $PATH env variable.

Kubernetes version (use kubectl version): v1.13.1

Environment:

  • Kernel (e.g. uname -a): macOS 10.14.2.

What happened:

I have this env var:

echo $PATH
/Users/ahmetb/.krew/bin:/Users/ahmetb/workspace/dotfiles/bin:/Users/ahmetb/.homebrew/opt/python/libexec/bin:/Users/ahmetb/.homebrew/opt/ruby/bin:/Users/ahmetb/.homebrew/opt/gnu-sed/libexec/gnubin:/Users/ahmetb/.homebrew/opt/openssl/bin:/Users/ahmetb/.homebrew/opt/gettext/bin:/Users/ahmetb/.homebrew/opt/ncurses/bin:/Users/ahmetb/.homebrew/opt/grep/libexec/gnubin:/Users/ahmetb/.homebrew/opt/gnu-sed/libexec/gnubin:/Users/ahmetb/.homebrew/opt/gnu-tar/libexec/gnubin:/Users/ahmetb/.homebrew/opt/gnu-indent/libexec/gnubin:/Users/ahmetb/.homebrew/opt/gnu-getopt/libexec/gnubin:/Users/ahmetb/.homebrew/opt/coreutils/libexec/gnubin:/Users/ahmetb/.homebrew/bin:/Users/ahmetb/.homebrew/sbin:/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:~/.dotnet/tools:/Users/ahmetb/gotools/bin:/Users/ahmetb/.homebrew/opt/fzf/bin
$ kubectl plugin list

error: unable to read directory "/Users/ahmetb/.krew/bin" in your PATH: open /Users/ahmetb/.krew/bin: no such file or directory
error: unable to read directory "/Users/ahmetb/.homebrew/opt/gnu-indent/libexec/gnubin" in your PATH: open /Users/ahmetb/.homebrew/opt/gnu-indent/libexec/gnubin: no such file or directory
error: unable to read directory "/Users/ahmetb/.homebrew/opt/gnu-getopt/libexec/gnubin" in your PATH: open /Users/ahmetb/.homebrew/opt/gnu-getopt/libexec/gnubin: no such file or directory
error: unable to read directory "~/.dotnet/tools" in your PATH: open ~/.dotnet/tools: no such file or directory
error: unable to find any kubectl plugins in your PATH

What you expected to happen:

Don't print error: unable to read directory for dirs that don't exist. This should be a -v=3 level bug.

/kind bug
/priority P1

I suspect this might be by design. But I feel like I didn't hit this in v1.12 and this still should not be an error. Many users may have dirs in PATH that no longer exist, this error is an overkill for those people.

/remove-priority P1
/priority P2

I actually have the ~/.dotnet/tools directory and it is in my path, but i do get the same error

$ kubectl plugin list
The following kubectl-compatible plugins are available:

/Users/xxx/.krew/bin/kubectl-krew

error: unable to read directory "~/.dotnet/tools" in your PATH: open ~/.dotnet/tools: no such file or director

The ~/.dotnet/tools is empty.

kubectl version: Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def"

/assign

@ahmetb

I suspect this might be by design. But I feel like I didn't hit this in v1.12 and this still should not be an error. Many users may have dirs in PATH that no longer exist, this error is an overkill for those people.

Agree. kubernetes/kubernetes#73542

I actually have the ~/.dotnet/tools directory and it is in my path, but i do get the same error

I'm running into this as well. I can't tell where this is being set. I can't find it in any of the standard places PATH is set if anyone knows that. I tried changing permissions as well and it stills says it can't find that directory. Anyone know how to resolve this?

@brennancheung It's better if you ask the dotnet project how/why they're injecting directories like that into your PATH variable. This is fixed in Kubectl since v1.14.0, so make sure you're using a newer version to get rid of the error messages in the original message. This is not specific to dotnet.

It still shows the error which is kind of annoying. I'm on 1.17. The directory exists so I don't know why kubectl would be complaining. That is the primary issue that I think is still not resolved.

❯ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T23:35:15Z", GoVersion:"go1.14.2", Compiler:"gc", Platform:"darwin/amd64"}
error: You must be logged in to the server (the server has asked for the client to provide credentials)

❯ kubectl plugin list
Unable read directory "~/.dotnet/tools" from your PATH: open ~/.dotnet/tools: no such file or directory. Skipping...
error: unable to find any kubectl plugins in your PATH

Still showing up the error.

The folder does exists

❯ ls  -la ~/.dotnet/tools
total 0
drwxr-xr-x  2 ubi  staff   64 Apr 21 09:51 .
drwxr-xr-x  4 ubi  staff  128 Apr 21 09:51 ..

I facing the same issue. I am getting issues for multiple paths which are not present in the file system like C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Local\\Microsoft\\WindowsApps and %USERPROFILE%?go/bin. I have looked at the linked PR but I am failing to understand why would the plugin list command need to tell me if path variables exist or not. I can understand that kubectl plugins are checked from the path but I don't think it's necessary to log the inexistance of a path.

toroc commented

This same issue is happening on my Mac:

~ kubectl plugin list
Unable read directory "/usr/local/go/bin" from your PATH: open /usr/local/go/bin: no such file or directory. Skipping...
error: unable to find any kubectl plugins in your PATH

Version

~ kubectl version
Client Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.6-beta.0", GitCommit:"e7f962ba86f4ce7033828210ca3556393c377bcc", GitTreeState:"clean", BuildDate:"2020-01-15T08:26:26Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.2", GitCommit:"a02f27a", GitTreeState:"clean", BuildDate:"2020-04-13T12:04:13Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}

@brennancheung and @yordis in the case of ~/.dotnet/tools, I think the error message is because of the ~.

It is strange because I have dotnet tools installed, and in my path, it shows as "/home/bpursley/.dotnet/tools" and so I don't have the same problem.

In fact, I have to explicitly try to get it in my path with the ~ by wrapping it in single quotes, like this:

export PATH=$PATH:'~/.dotnet/tools'

And then I am able to reproduce the error message you're seeing:

Unable read directory "~/.dotnet/tools" from your PATH: open ~/.dotnet/tools: no such file or directory. Skipping...

Can you try updating your PATH to convert ~ into an absolute path?

@toroc Are you able to ls /usr/local/go/bin?

On macOS 11.3 I did this to fix the error:

sudo vim /etc/paths.d/dotnet-cli-tools 

and in that file replaced ~/.dotnet/tools

with absolute path: /Users/aleksei/.dotnet/tools