kubectl-ai icon indicating copy to clipboard operation
kubectl-ai copied to clipboard

fix(tools): Use exec.LookPath to find bash executable before running bash commands

Open ruinshe opened this issue 6 months ago • 3 comments

Fixes #228

Find the bash executable using exec.LookPath instead of hardcoding /bin/bash. Falls back to /bin/bash if not found in PATH. Improves compatibility on systems where bash might be installed in a non-standard location.

On some systems (e.g. NixOS), executables might not be in standard locations like /bin/bash.

ruinshe avatar May 14 '25 07:05 ruinshe

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar May 14 '25 07:05 google-cla[bot]

Currently I modified the bashBin in bash_tool.go in init function directly, if you think it's not a good choice and prefer passing the bash command path using parameters, or using other ways, please that me know.

ruinshe avatar May 14 '25 07:05 ruinshe

Currently I modified the bashBin in bash_tool.go in init function directly, if you think it's not a good choice and prefer passing the bash command path using parameters, or using other ways, please that me know.

Would prefer to keep init() side-effect free, suggested to move it closer to command construction. and its okay to duplicate code if needed.

droot avatar May 14 '25 20:05 droot

Thanks @ruinshe you will need to rebase the PR because we had to update the presubmits, sorry :(

droot avatar May 15 '25 03:05 droot

Thanks @ruinshe you will need to rebase the PR because we had to update the presubmits, sorry :(

done

ruinshe avatar May 15 '25 03:05 ruinshe