Issue
A most bizarre experience that I cannot explain and has me pulling my hair out. I have a binary executable file MMM and it exists, I can see it it has the x permission set, bash even autocompletes the name when I press the TAB key and file confirms its executable but this happens:
~/tmp$ ls -l
total 56
-rwxrwxr-x 1 polyphemus polyphemus 56948 Jun 25 22:43 MMM
~/tmp$ file MMM
MMM: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 2.2.5, stripped
~/tmp$ ./MMM
-bash: ./MMM: No such file or directory
So I copied this file from another server, and to make sure I haven't got some strange file corruption going on, not that that would explain bash's ridiculous claim the file does not exist, I copied the file to a NAS and from the NAS back to another server and repeated exactly the same experiment, only this happens:
~/tmp$ ls -l
total 56
-rwxr-xr-x 1 bernd bernd 56948 Jun 25 22:53 MMM
~/tmp$ file MMM
MMM: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 2.2.5, stripped
~/tmp$ ./MMM
JAVA_HOME is not set. ./MMM cannot start.
if it helps they are both Linux Mint boxes, the one where it works is a development machine with Mint 19 and the one where it's not working is a fresh install of Mint 19.1.
The install works fine, other executables run fine and I can run then in bash with ./file.
I've studied and compared the shopts and found nothing, the aliases and found nothing. This has me pulling my hair out. I hope someone has seen this before.
Solution
Thanks to pointers that Dennis Williamson provided the problem can be characterised as follows:
- It's a well known issue. In that there is a kernel limitation that means bash only receives a status code (the one for "file not found") without any descriptive data, when the kernel attempts to load a file needed to run the binary. The message is indeed frustratingly misleading and this is a broadly known and understood issue.
- As noted in the question itself this is an ELF binary: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format and the interpreter required for such a binary file can be divined with
readelf -a MMM | grep interpreter
which produces[Requesting program interpreter: /lib/ld-linux.so.2]
- It's easy to see this file is missing on my system and it turns out that to install it we need simply to install the libc6 libraries for 32 bit architecture with
sudo apt install libc6:i386
After doing this the problem scenario that was confusing me now looks like the working scenario:
~/tmp$ ls -l
total 56
-rwxrwxr-x 1 polyphemus polyphemus 56948 Jun 25 22:43 MMM
~/tmp$ file MMM
MMM: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 2.2.5, stripped
~/tmp$ ./MMM
JAVA_HOME is not set. ./MMM cannot start.
And the binary runs just fine!
A pleasing result. With many thanks to StackOverflow and to Dennis Williamson.
Answered By - Bernd Wechner Answer Checked By - Mildred Charles (WPSolving Admin)