Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go: “no such file or directory” but it exists

Tags:

go

I installed the golang.

~/go/bin$ ls
go  godoc  gofmt

Trying to test, but to no avail.

~/go/bin$ go version
-bash: /home/orc/go/bin/go: no such file or directory

My $PATH:

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/orc/go/bin:

Info:

~/go/bin$ uname -m
x86_64

~/go/bin$ file go
go: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

~/go/bin$ pwd
/home/orc/go/bin

Please tell me what's wrong?

UPDATE

~/go/bin$ ls -l
итого 28688
-rwxr-xr-x 1 orc orc 9571864 Фев 18 14:40 go
-rwxr-xr-x 1 orc orc 16164032 Фев 18 14:41 godoc
-rwxr-xr-x 1 orc orc 3594712 Фев 18 14:40 gofmt

~/go/bin$ ./go
-bash: ./go: Нет такого файла или каталога

!!!

~/go/bin$ file $(which ls)
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

~/go/bin$ uname -a
Linux olimp-web 2.6.32-5-amd64 #1 SMP Mon Jun 13 05:49:32 UTC 2011 x86_64 GNU/Linux

Please explain how to fix it?

like image 407
user3514212 Avatar asked Mar 30 '15 03:03

user3514212


People also ask

Why do I keep getting no such file or directory?

log No such file or directory” the problem is most likely on the client side. In most cases, this simply indicates that the file or folder specified was a top-level item selected in the backup schedule and it did not exist at the time the backup ran.

How fix bash No such file or directory?

To fix it, try the dos2unix program if you have it, or see Converting DOS Files to Linux Format. Note that if you use dos2unix it will probably create a new file and delete the old one, which will change the permissions and might also change the owner or group and affect hard links.

How do I set up a Gopath?

Open settings ( Ctrl+Alt+S ) and navigate to Go | GOPATH. In the file browser, navigate to the directory that you want to associate with GOPATH. In the following example, we configured to use different GOPATH directories for different scopes. GoLand will use the Module GOPATH as it is the narrowest scope configured.

Can't open file No such file or directory Linux?

The Python "FileNotFoundError: [Errno 2] No such file or directory" occurs when we try to open a file that doesn't exist in the specified location. To solve the error, move the file to the directory where the Python script is located if using a local path, or use an absolute path.


3 Answers

Have you checked that you have the correct version for your architecture installed. I have just had this exact problem when I put a 32-bit binary on a 64-bit virtual machine. I removed the 32-bit version and installed the architecture appropriate version (based on the instructions on the website) and it worked. Hope that works for you too.

like image 110
PJeffes Avatar answered Oct 31 '22 14:10

PJeffes


A couple of things to check, which may come to nothing, but they'll at least rule out things:

  1. There's no indication in your question that your current directory is within /home/orc, a simple pwd should clarify that.

  2. Can you run the file directly, such as with ./go or ~/go/bin/go?

  3. Is it executable? The output of ls -l should clarify that.

  4. Get the full machine details with uname -a.

  5. Check the system executables in case it's somehow not 64-bit, despite the indication: file $(which ls).

  6. Make sure there's no funny characters in the path that would prevent it being picked up there: echo $PATH | od -xcb.

  7. Make sure your GOPATH is set up correctly (not sure this would affect go version but it's something extra to try).

like image 24
paxdiablo Avatar answered Oct 31 '22 13:10

paxdiablo


In my case go compiler and language were not installed...

sudo apt install golang-go
like image 24
Pipo Avatar answered Oct 31 '22 13:10

Pipo