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

When using direnv (envrc.el / Doom Emacs) : kubectl no such file or directory #90

Open
efim opened this issue Jun 19, 2022 · 1 comment

Comments

@efim
Copy link

efim commented Jun 19, 2022

Hello!
I've encountered a problem (which has a workaround - just install kubectl globally on the system), with which I'm asking for a bit of help.

Direnv - is a tool for specifying environment (variables) for a directory and automatically setting them up when visiting / working in the directory.
With Nix it's possible to have specific binary dependencies loaded to PATH only when working with specific directory, so for example "kubectl" can have a specific pinned version and only active when I'm working with "~/Documents/work/project-a"

There's emacs integration packages "envrc.el" and "direnv.el"

When I try to call (kubel) from buffer that has envrc environment setup to include "kubectl" on it's path I get buffer with error
/bin/bash: kubectl: command not found

If I check buffer with commands that kubel trying to execute with $, I can see for example
command: kubectl --context gke_develop -n pre-staging get services

and if I copy that command and execute with M-& in the *kubel (pre-staging)* buffer, I get output from kubectl - so async-shell-command has access to the correct environment when executed from kubel buffer

I've checked Troubleshooting section of "envrc" and it says:

If you find that a particular Emacs command isn't picking up the environment of your current buffer, and you're sure that envrc-mode is active in that buffer, then it's possible you've found code that runs a process in a temp buffer and neglects to propagate your environment to that buffer before doing so.

The inheritenv package was designed to handle this case in general.

Checking inheritenv command/marcos documentation - it's there to be used as a wrapper around sexp to make sure that it sees same environment as buffer that evaluates it, and also propagating environment to temporary buffers that could be created by the code.

I've tried to eval expression (inheritenv (kubel)) from the buffer where "kubectl" should be present and kubel seems to work - initial screen loads correctly.
Only if I try to change namespace or access logs, I get same error again "kubectl: command not found".

I suppose one way to try and solve this on user side is to wrap / advice whatever possible in inheritenv, maybe that would make things work.

And maybe someone would understand inner workings better and give me advice on how to maybe prepare an MR that would allow direnv integration?

Kubernetes-el doesn't work for me for magit-section problems with Doom Emacs, but it seems to pick up "kubectl" from direnv environment, so maybe it's not something that's hard to do for those who know where to look

efim pushed a commit to efim/dotfiles that referenced this issue Jun 25, 2022
doesn't pick up direnv binary, adding globally to the machine
with sadness
abrochard/kubel#90

maybe I'd be able to contribute, but how?
efim pushed a commit to efim/dotfiles that referenced this issue Jun 29, 2022
doesn't pick up direnv binary, adding globally to the machine
with sadness
abrochard/kubel#90

maybe I'd be able to contribute, but how?
@psibi
Copy link

psibi commented Dec 2, 2022

This PR will likely improve the situation: #110 as you can now whitelist the environment variable that can be passed to kubel.

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

2 participants