1

I installed Golang into a custom folder under $HOME called .go/exec. After the installation, it put the binary under $HOME/.go/exec/go.

So I updated $PATH to contain this directory: $HOME/.go/exec:$PATH.

Here is the question:

When I execute a command by entering the path manually, it works without any issues:

~/.go/exec/go/bin/go version

However, with $PATH it does not work:

go version
# zsh: permission denied: go

I am logged in with $USER, and seems like permissions are set correctly. Here is a namei output:

pwd
# /home/user

namei -olm ./.go/exec/go/bin/go

drwxr-x--- user user .
drwxrwxr-x user user .go
drwxrwxr-x user user exec
drwxr-xr-x user user go
drwxr-xr-x user user bin
-rwxr-xr-x user user go

Could anyone guide me where the issue is?

I thought just adding the top directory to $PATH should have been enough, am I wrong?

5
  • 2
    You should add to $PATHthe bin folder $HOME/.go/exec/go/bin instead of $HOME/.go/exec Commented Jul 5, 2024 at 9:38
  • 1
    @admstg please don't post answers as comments. That circumvents the voting mechanism since comments cannot be voted down, and will never mark the question as answered. Commented Jul 5, 2024 at 10:15
  • @admstg Thank you for the explanation, apparently I was wrong about $PATH resolution. Adding the bin to the path solved the issue. Commented Jul 6, 2024 at 10:18
  • @StéphaneChazelas You're right, I made a typo in there, I checked again and it did say zsh: permission denied: go. Thanks a lot for explaining the differences between the two! I will update the question to prevent confusion. Commented Jul 6, 2024 at 10:18
  • @BerkAçıkgöz You can check which path go is actually resolving to with whence go (or which go or where go which are aliases for whence with flags). This would have revealed the problem with your PATH variable. Commented Jul 23, 2024 at 4:38

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.