Today I started to notice weird behavior running a local command for a binary installed through Go. It seems the command is aliased, but consulting alias
, it isn't.
The command buf
somehow executes cp
!
buf --help
Usage: cp [OPTION]... [-T] SOURCE DEST
or: cp [OPTION]... SOURCE... DIRECTORY
or: cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Bash setup
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu) on Debian GNU/Linux 12 (bookworm).
I use Oh My Bash for fancy stuff with auto-updates enabled. This is my .bashrc
:
case $- in
*i*) ;;
*) return;;
esac
export OSH='/home/tim/.oh-my-bash'
OSH_THEME="font"
completions=(
git
ssh
go
docker
docker-compose
makefile
)
aliases=(
general
)
plugins=(
git
bashmarks
)
source "$OSH"/oh-my-bash.sh
export PATH="$PATH:/home/tim/.local/bin"
eval $(thefuck --alias)
export BUN_INSTALL="$HOME/.bun"
export PATH=$BUN_INSTALL/bin:$PATH
Failing command
The command was installed in GOPATH
using the go command:
go install github.com/bufbuild/buf/cmd/[email protected]
GOPATH
:
go env GOPATH
/home/tim/go
And the Go bin directory is part of PATH
:
echo $PATH
/home/tim/.bun/bin:/home/tim/go/bin:/home/tim/Repositories/goroot/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/tim/.local/bin:/home/tim/.local/bin
And a sanity check with which
resolves to the correct binary:
which buf
/home/tim/go/bin/buf
Executing the path directly works as expected:
/home/tim/go/bin/buf --help
The Buf CLI
...
Configured Aliases
There is no configured alias for buf
:
alias buf
bash: alias: buf: not found
Other notes
I've installed Debian just a few months ago. I'm not sure if I ever tried to run buf
directly after that. However, my home directory was restored from a backup created from OpenSUSE, on which I'm sure I've run the buf
command successfully. Oh My Bash, the Go installation and go binaries were both part of that backup. Most stuff did get updated meanwhile, but I don't remember changing any config.
Other Go binaries work as expected:
cobra-cli --help
Cobra is a CLI library for Go that empowers applications.
For my daily work buf
is also used, but through a MakeFile. When invoked through make
it runs just fine.
How can the buf
command executed cp
when I can't find an alias and the PATH
is the correct one? Are there other ways of aliasing commands I'm not aware of?
type -a buf
buf --help
saysThe Buf CLI A tool for working with Protocol Buffers and managing resources on the Buf Schema Registry (BSR)
so there is an issue in your setup most likely.buf
might be a function or something earlier in$PATH
.