-bash: Go: command not found

0

Dear All,

I have installed the GO lang into Linux Amazon and updated in the "./bash_profile" but when I run the "go version", the error remains the same --> "-bash: Go: command not found"

Kindly refer to the copied and pasted of the "./bash_profile" below:

(#) .bash_profile

(#) Get the aliases and functions if [ -f ~/.bashrc ]; then     . ~/.bashrc fi

(#) User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin

(#) GOROOT is the location where Go package is installed on your system export GOROOT=/usr/local/go

(#) GOPATH is the location of your work directory export GOPATH=$HOME/go

(#) CASERVICEENDPOINT is the endpoint to reach your member's CA (#) for example ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n-MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30002 export CASERVICEENDPOINT=MyMemberCaEndpoint

(#) ORDERER is the endpoint to reach your network's orderer (#) for example orderer.n-MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 export ORDERER=MyNetworkOrdererEndpoint

(#) Update PATH so that you can access the go binary system wide export PATH=$GOROOT/bin:$PATH export PATH=$PATH:/home/ec2-user/go/src/github.com/hyperledger/fabric-ca/bin

export PATH=$PATH:/usr/local/go/bin

export PATH="$HOME/bin:$PATH"

Can anyone see if there's a mistake command line that should not be in the "/.bash_profile"?

Thanks.

asked a year ago494 views
1 Answer
0

-bash: Go: command not found

Looks like an upper-case G there, go should be all lower case.

If you still have no joy then look for the path to the binary, and then you can work out whay it's not in yout $PATH. From what you've pasted above it looks like it should be somewhere under /usr/local/go or in ec2-user's home directory, so start with these.

find ~ /usr/local -name go -type f -exec ls -ld {} \;

Did that find it?

profile picture
EXPERT
Steve_M
answered a year ago
  • Hi @RWC,

    Sorry about the typo error:

    [ec2-user@ip-172-31-22-105 ~]$ go version -bash: go: command not found

    Whether is Go or go is still the same as the above pasted.

    Also, for the command line you asked me to find, here you are the results:

    [ec2-user@ip-172-31-22-105 ~]$ find ~ /usr/local -name go -type f -exec ls -ld {} ; -rwxr-xr-x. 1 ec2-user ec2-user 15645180 Apr 26 15:35 /home/ec2-user/go/bin/go -rwxr-xr-x. 1 root root 15645326 Mar 29 21:19 /usr/local/go/bin/go/bin/go -rwxr-xr-x. 1 ec2-user ec2-user 15645180 Apr 26 15:35 /usr/local/go/go/bin/go

    Based on the above, which one I need to amend in my /.bash_profile? Please advice, thanks.

  • The last bit of your .bash_profile that starts Update PATH so that you can access the go binary system show that it is expecting to find the go binary in either /usr/local/go/bin or /home/ec2-user/bin. But it's not in either of them.

    It looks like you've tried to install it three times, all into different locations. You first installed it into /usr/local/go/bin/go/bin and later on into /home/ec2-user/go/bin and /usr/local/go/go/bin

    You can append one of these locations onto your PATH and it will use that, but you're probbaly storing up trouble for yourself further down the line by having three copies of the software installed in separate places - what happens when it's time for a critical patch or an upgrade? I wouldn't be surprised if this also means things that it depends on like libraries are at non-standard locations too.

    The cleanest thing to do would actually be to uninstall all three copies of the software at the different locations, and then install from scratch into the default location.

  • Hi @RWC,

    The problem has been resolved. It is because of my Mac system SSH Connecting to Linux Amazon, I should be using ARM instead of AMD, which is why causing lots of trouble.

    See this below:

    wget https://dl.google.com/go/go1.20.4.linux-arm64.tar.gz tar -xzf go1.20.4.linux-arm64.tar.gz go version go version go1.20.4 linux/arm64

    Yes, I have deleted the previous as you've suggested.

    Thanks so much for your help and I do learned from you too.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions