devspace
devspace copied to clipboard
devspace completion prints info statement that results in command not found when executed/sourced
What happened?
Running source <(devspace completion bash) causes the error below:
bash: ommand not found...
bash: 36m[info]: command not found...
This happens when one of the parent folders of the current working directory contains a devspace.yaml file. For me, this happens when I open a new tab or split a terminal in my terminal emulator while in a subfolder of a project that uses devspace.
What did you expect to happen instead?
Not printing [info] Using devspace config in ... when running devspace completion, and thus no error message.
How can we reproduce the bug? (as minimally and precisely as possible)
cd /tmp && mkdir test && cd test && touch devspace.yaml && mkdir subfolder && cd subfolder/ && devspace completion bash | head -n 1
You will see [info] Using devspace config in /tmp/test printed.
Instead, you should see something like # bash completion for devspace ...
Local Environment:
- DevSpace Version: 5.18.2
- Operating System: linux
- ARCH of the OS: AMD64
Workaround:
source <(devspace completion bash | grep -v -e "Using devspace config in")
/kind bug
I had a quick look at the code.
The info message in question gets printed by configLoader.SetDevSpaceRoot() that's called from cmd.getCommands() here - https://github.com/loft-sh/devspace/blob/a5eac169596719ace76d4824fb8e1b085581dc25/cmd/run.go#L206
I couldn't quickly come up with an elegant solution that would preserve all other functionality, so I'll probably leave this to folks more familiar with the code base. :)