No such file when it exists
Solution 1:
The shell will report an ambiguous "No such file or directory" for an executable when the shell cannot find a dependency for that executable.
The missing dependency is typically a required shared library or a dynamic loader.
Use the strace command to explicitly view the open() syscall that fails during the execution request (e.g. strace /usr/local/phantomjs/bin/phantomjs
).
Addendum
execve("/usr/local/phantomjs/bin/phantomjs", ["/usr/local/phantomjs/bin/phantom"...], [/* 13 vars */]) = -1 ENOENT (No such file or directory)
The evecve syscall returned the error code ENOENT, which the man page describes as "the file filename or a script or ELF interpreter does not exist, or a shared library needed for file or interpreter cannot be found."
Usually I've seen strace provide better resolution of the missing file.
The next step is to examine the executable file for its dependencies.
Use the strings command to extract the dynamic linker/loader, shared libraries, and entry-points listed at the beginning of the executable file.
strings /usr/local/phantomjs/bin/phantomjs | less
For each filename that you can identity in this list, you then have to verify that the file is installed in your root filesystem.
$ file modetest
modetest: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.10.0, stripped
$ strings modetest | less
/lib/ld-linux-armhf.so.3 <=
libdrm.so.2 <=
drmModeFreeObjectProperties
drmModeFreePlaneResources
_ITM_deregisterTMCloneTable
...
libpthread.so.0 <=
pthread_join
pthread_create
__errno_location
...
libc.so.6 <=
strcpy
exit
mmap64
...
From your previous Update2, the first file would be /lib64/ld-linux-x86-64.so.2.