I have a container running go1.18. But I am not able to execute a go binary file on it.
The error I get is No such file or directory even though the file exists on the system.
root#b5840a7e3deb:/goapp# go get bitbucket.xvz.com/xxx_gosdk/genlog
go: downloading bitbucket.xvz.com/xxx_gosdk/genlog v0.0.0-20180720150703-5438fece8851
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/pkg/errors v0.9.1
root#b5840a7e3deb:/goapp# go generate ./applogs/...
applogs/loggen.go:2: running "genlog": exec: "genlog": executable file not found in $PATH
root#f27b28c39c4b:/goapp# echo $PATH
/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin
root#f27b28c39c4b:/goapp# find . -name genlog
./target/bin/genlog
root#f27b28c39c4b:/goapp# export PATH=/goapp/target/bin:$PATH
root#f27b28c39c4b:/goapp# go generate ./applogs/...
applogs/loggen.go:2: running "genlog": exec: "genlog": executable file not found in $PATH
root#f27b28c39c4b:/goapp# ./target/bin/genlog
bash: ./target/bin/genlog: No such file or directory
root#f27b28c39c4b:/goapp# ls -ltr ./target/bin/genlog
-rwxr-xr-x 1 root root 5785472 Jul 15 11:55 ./target/bin/genlog
root#b5840a7e3deb:/goapp# cd target/bin/
root#b5840a7e3deb:/goapp/target/bin# ./genlog
bash: ./genlog: No such file or directory
root#f27b28c39c4b:/goapp# go version
go version go1.18.3 linux/amd64
Not sure what could be the reason of this?
Both file and linux are 64-bit.
root#b5840a7e3deb:/goapp/target/bin# file genlog
genlog: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, Go BuildID=5_YjQVva2uu05mM9OtMl/4DKTh04b6KayyO-oCXMx/S56k25kGovKc_B70LVqf/UnqDZDQQtMFSIfz-py0j, not stripped
root#b5840a7e3deb:/goapp/target/bin# uname -a
Linux b5840a7e3deb 5.4.17-2136.308.9.el7uek.x86_64 #2 SMP Mon Jun 13 20:40:51 PDT 2022 x86_64 x86_64 x86_64 GNU/Linux
Update: I figured that I was missing a program interpreter which I installed using apt-get. But `ldd` is still complaining that the interpreter is missing.
root#f718aa896bd6:/goapp/target/bin# ldd genlog
linux-vdso.so.1 (0x00007ffedee39000)
libc.musl-x86_64.so.1 => not found
root#f718aa896bd6:/goapp/target/bin# readelf -a genlog | grep interpreter
[Requesting program interpreter: /lib/ld-musl-x86_64.so.1]
root#f718aa896bd6:/goapp# ls /lib/ld-musl-x86_64.so.1
ls: cannot access '/lib/ld-musl-x86_64.so.1': No such file or directory
root#f718aa896bd6:/goapp# apt-get install musl
...
Unpacking musl:amd64 (1.1.24-1) ...
Setting up musl:amd64 (1.1.24-1) ...
root#f718aa896bd6:/goapp# cd target/bin/
root#f718aa896bd6:/goapp/target/bin# ls -ltr /lib/ld-musl-x86_64.so.1
lrwxrwxrwx 1 root root 25 Oct 13 2019 /lib/ld-musl-x86_64.so.1 -> x86_64-linux-musl/libc.so
root#f718aa896bd6:/goapp/target/bin# ./genlog
genlog: error while reading file '': open : no such file or directory
root#f718aa896bd6:/goapp/target/bin# ldd genlog
linux-vdso.so.1 (0x00007ffedee39000)
libc.musl-x86_64.so.1 => not found
root#f718aa896bd6:/goapp/target/bin# readelf -a genlog | grep interpreter
[Requesting program interpreter: /lib/ld-musl-x86_64.so.1]
Related
I have the following file xx.sh:
#!/bin/bash
echo "hi"
The permissions are defined as follows:
-rwxr-xr-x 1 root root 22 Nov 22 10:55 xx.sh*
but when I run the file ./xx.sh I get:
**-bash: ./xx.sh: Permission denied**
When running with override: bash xx.sh it runs correctly.
What is the permission issue here?
Your system is probably mounted with noexec. Verify by:
findmnt <folder>
If you have noexec in the OPTIONS, then you are not allowed to execute executable binaries in the mounted file system. You can solve using the mount command.
I'm having trouble using the CLion integration environment under linux.
When I execute a script using the system terminal, it is possible to run.
compile_test.sh:
#!/bin/bash
if [ ${USER} == "mzflrx" ]
then
LLVM_PATH="/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04"
else
LLVM_PATH="/home/devin812/文档/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04"
fi
# 生成待保护的字节码
${LLVM_PATH}/bin/clang -o3 -emit-llvm test.c -c -o test.bc
# 生成可执行文件(保护前)
${LLVM_PATH}/bin/clang test.bc -o test -lpthread
But when I execute with CLion's built-in terminal, I get the following error:
[mzflrx#mzflrx test]$ ls
compile_out_cpp.sh compile_test.sh out1 out.bc test test-37.cpp test.c test.i64
compile_out.sh data.txt out1.bc out.i64 test-377.cpp test-37.ll testcase test.ll
compile_test_cpp.sh generate_cpp.sh out1.ll result.txt test-37.bc test.bc test.cpp test_time.py
[mzflrx#mzflrx test]$ ./compile_test.sh
/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
/home/mzflrx/Downloads/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/llvm-dis: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
I don't know why I can't find the library.
In the CLion built-in terminal, I go into the /usr/lib directory to execute the ls command.
[mzflrx#mzflrx test]$ cd /usr/lib
[mzflrx#mzflrx lib]$ ls
aarch64-linux-gnu extensions ld-linux-aarch64.so.1 locale perl5 systemd udev
arm-linux-gnueabihf gcc ld-linux-armhf.so.3 os-release python3.8 tcl8.6 x86_64-linux-gnu
debug i386-linux-gnu ld-linux.so.2 perf sdk terminfo
In the linux terminal, I go into the /usr/lib directory to execute the ls command.
$: cd /usr/lib
$: ls | head -n20
accounts-daemon
alsa-lib
ao
apparmor
appimagelauncher
appstreamcli-compose
asb-plugins-5
at-spi2-registryd
at-spi-bus-launcher
audit
avahi
awk
baloo_file
baloo_file_extractor
baloorunner
bash
bellagio
bfd-plugins
binfmt.d
bluetooth
Twice the same command gets completely different results on different consoles.
I don't know why, is it because the CLion built-in console is using a virtual environment?
But it's no use removing active-virtualenv option from the file->setting->Tool->Terminal
I know why there is such a reason. Because I use flatpak to install, it has its own virtual environment. It's fine after I use the source code to install
I've got a quite strange problem with golang and Makefile (on Fedora 33).
My Makefile contains:
run:
go run main.go
which should only print "Hello" to the console. When I run make run I get this error:
go run main.go
make: go: Permission denied
make: *** [Makefile:5: run] Error 127
However, if I change my Makefile to
run:
/usr/bin/go run main.go
it works just fine!
INFO
Outputs of:
$ which go
/usr/bin/go
$ go version
go version go1.15.5 linux/amd64
$ uname -a
Linux localhost.localdomain 5.9.10-200.fc33.x86_64 #1 SMP Mon Nov 23 18:12:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Can someone help me with this? If you need more info please tell me!
Thank you!
EDIT
Console
$ echo ${PATH}
/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/home/olena/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin
Output of make
echo /usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/home/olena/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin
/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/home/olena/bin:/usr/local/sbin:/usr/sbin:/var/lib/snapd/snap/bin
go run main.go
make: go: Permission denied
make: *** [Makefile:6: run] Error 127
In /usr/bin
$ ll | grep go
lrwxrwxrwx. 1 root root 20 Nov 14 09:32 go -> /etc/alternatives/go
In /etc/alternatives
$ ll | grep go
lrwxrwxrwx. 1 root root 22 Nov 29 15:16 go -> /usr/lib/golang/bin/go
I ran to the same issue as yours and finally figured out what was wrong with mine. Maybe this works for you, especially if you use zsh with omz.
In my case, one of the locations defined in $PATH contains a folder named go. That location came before where go binary was in. Once I put that location to be after the binary location, everything just worked.
I believe maybe it has something to do with omz and how its shell functions allow you to go into a folder.
you can add '#' before command to hide output in terminal
run:
#/usr/bin/go run main.go
it outputs only 'Hello'
Using Windows, I installed Rakudo Star and Git and ensured that C:\rakudo\bin and C:\rakudo\share\perl6\site\bin are in my Path environment variable.
Now, typing perl6 inside Git Bash afterwards gives the command not found error, while the command does work inside powershell and cmd. Typing echo $PATH inside Git Bash confirms again that the folders above are in my path variable here as well.
How can I get the perl6 command working inside Git Bash?
Note: Using moar (moar.exe) which resides in the same folder as perl6 works as well in Git Bash. Also hitting Tab show the autocomplete suggestion for moar, it does not do that for perl6.
Bash doesn't run Windows batch files, so you'll have to work around that.
An easy solution might be to add something like this you your .bashrc:
alias perl6='cmd /c perl6.bat'
Alternatively, you can convert perl6.bat to a shell script and put it somewhere in your $PATH.
I use the following:
#!/bin/sh
PATH=/cygdrive/c/rakudo/bin:/cygdrive/c/rakudo/share/perl6/site/bin:$PATH
unset HOME
moar --execname="$0" \
--libpath='C:\rakudo\share\nqp\lib' \
--libpath='C:\rakudo\share\perl6\lib' \
--libpath='C:\rakudo\share\perl6\runtime' \
'C:\rakudo\share\perl6\runtime\perl6.moarvm' \
"$#"
This is using Cygwin; you may need to adapt it a bit for Git bash (I don't know, no experience with it).
Alternatively, if you're using Windows 10, I can recommend installing WSL, and using perl6 in a WSL bash prompt instead. This runs much smoother for me than the Windows version under Cygwin.
I tried to install perl6 from the link you provided and I can confirm the same behavior on Cygwin on Windows 10.
If I type in the Cygwin terminal window:
$ perl6
-bash: perl6: command not found
$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Users/Bruker/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/rakudo/bin:/cygdrive/c/rakudo/share/perl6/site/bin
$ cd /cygdrive/c/rakudo/bin
$ ls -l
-rwxrwx---+ 1 SYSTEM SYSTEM 930663 May 11 2017 libgcc_s_seh-1.dll
-rwxrwx---+ 1 SYSTEM SYSTEM 136146 Mar 30 20:55 libmoar.dll.a
-rwxrwx---+ 1 SYSTEM SYSTEM 56978 May 11 2017 libwinpthread-1.dll
-rwxrwx---+ 1 SYSTEM SYSTEM 7021172 Mar 30 20:55 moar.dll
-rwxrwx---+ 1 SYSTEM SYSTEM 64066 Mar 30 20:55 moar.exe
-rwxrwx---+ 1 SYSTEM SYSTEM 126 Mar 30 20:56 nqp.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 126 Mar 30 20:56 nqp-m.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 242 Mar 30 20:56 perl6.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 248 Mar 30 20:56 perl6-debug-m.bat
-rwxrwx---+ 1 SYSTEM SYSTEM 242 Mar 30 20:56 perl6-m.bat
$ cat perl6.bat
# "C:\rakudo\bin\moar" --execname="%~dpf0" --libpath="C:\rakudo\share\nqp\lib" --libpath="C:\rakudo\share\nqp\lib" --libpath="C:\rakudo\share/perl6/lib" --libpath="C:\rakudo\share/perl6/runtime" C:\rakudo\share\perl6\runtime\perl6.moarvm %*
Notice that the paths in the bat file are not cygwin paths. So that might explain why it does not work..
For example:
$ "C:\rakudo\bin\moar"
-bash: C:\rakudo\bin\moar: command not found
$ /cygdrive/c/rakudo/bin/moar
ERROR: Missing input file.
USAGE: moar [--crash] [--libpath=...] input.moarvm [program args]
moar --dump input.moarvm
moar --help
[...]
Update:
I also tried install Git Bash, and then from the MINGW64 terminal window:
$ echo $PATH
/c/Users/Bruker/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Bruker/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Users/Bruker/AppData/Local/Microsoft/WindowsApps:/usr/bin/vendor_perl:/usr/bin/core_perl
$ PATH=/c/rakudo/bin:$PATH
$ perl6
bash: perl6: command not found
$ moar
ERROR: Missing input file.
USAGE: moar [--crash] [--libpath=...] input.moarvm [program args]
moar --dump input.moarvm
moar --help
[...]
Note that moar is an .exe file while perl6 is a .bat file.
Also it seems perl6 is not "offical" for Cygwin yet according to this issue.
I'm attempting to install https://github.com/jehiah/json2csv. The problem is apparently tied to my noob status w.r.t. Bash.
System: Ubuntu 14.04 LTS
Load instruction:
$ go get github.com/jehiah/json2csv
Go is installed:
$ which go ==> /usr/bin/go
~/.bashrc setup:
export GOROOT=/usr/bin/go
export GOPATH=$HOME/projects/go
The package seems to download correctly:
$ cd projects/go
$ tree
$ > bin > json2csv
> src > github.com
...
$ ls bin -l
$ > -rwxrwxr-x 1 <user> <user> 55400 Feb 5 13:57 json2csv
But $json2csv isn't recognized, even from the same directory. I'm sure this is a noob problem, but I haven't cracked it yet. Suggestions?
Add $GOPATH/bin to your PATH variable in your shell,
for bash:
export PATH=$GOPATH/bin:$PATH