今天又學了一招,牛逼!!!解決"-bash:No such file or directory"問題


今天在64服務器上:發現好像bash 壞了,用戶名前邊   用-bash 顯示,,前幾天就發現這個問題,,,但是當時忙沒有解決,,,,,今天來看看到底是怎么回事!

 

File Exists but... "-bash: No such file or directory"

 

網上找到一篇文章,是說ubuntu系統的,我現在使用的是RHEL6.1 ,先不說其他的,先實踐再說,完了看效果!!

-----------------粘貼網上原文---------原文地址:http://superuser.com/questions/344533/no-such-file-or-directory-error-in-bash-but-the-file-exists

On Ubuntu, I get a 'No such file or directory' error when I try to execute a command.

I have checked with ls -la , the file adb is there and it has 'x' flag So why I am getting a 'No such file or directory'?

~/Programs/android-sdk-linux_x86/platform-tools$ ./adb bash: ./adb: No such file or directory ~/Programs/android-sdk-linux_x86/platform-tools$ ls -la total 34120 drwxrwxr-x 3 silverstri silverstri 4096 2011-10-08 18:50 . drwxrwxr-x 8 silverstri silverstri 4096 2011-10-08 18:51 .. -rwxrwxr-x 1 silverstri silverstri 3764858 2011-10-08 18:50 aapt -rwxrwxr-x 1 silverstri silverstri 366661 2011-10-08 18:50 adb -rwxrwxr-x 1 silverstri silverstri 906346 2011-10-08 18:50 aidl -rwxrwxr-x 1 silverstri silverstri 328445 2011-10-08 18:50 dexdump -rwxrwxr-x 1 silverstri silverstri 2603 2011-10-08 18:50 dx drwxrwxr-x 2 silverstri silverstri 4096 2011-10-08 18:50 lib -rwxrwxr-x 1 silverstri silverstri 14269620 2011-10-08 18:50 llvm-rs-cc -rwxrwxr-x 1 silverstri silverstri 14929076 2011-10-08 18:50 llvm-rs-cc-2 -rw-rw-r-- 1 silverstri silverstri 241 2011-10-08 18:50 llvm-rs-cc.txt -rw-rw-r-- 1 silverstri silverstri 332494 2011-10-08 18:50 NOTICE.txt -rw-rw-r-- 1 silverstri silverstri 291 2011-10-08 18:50 source.properties
share improve this question
 
    
what do you get if you run file adb – jdigital Oct 9 '11 at 5:43
    
i get this '$ file adb adb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped ' – michael Oct 13 '11 at 3:56

7 Answers

up vote 14down voteaccepted

It's an executable file that misses required libraries. Use ldd to see what it needs, then provide these files.

share improve this answer
 
10  
i get this '$ ldd ./adb not a dynamic executable' – michael Oct 11 '11 at 0:36

Android SDK requires 32-bit libraries. You probably are on 64-bit and need the 32-bit libs. Here are the troubleshooting directions from developer.android.com

For Ubuntu 13.10 (Saucy Salamander) and above, install the libncurses5:i386libstdc++6:i386, and zlib1g:i386 packages using apt-get:

sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386

For earlier versions of Ubuntu, install the ia32-libs package using apt-get:

apt-get install ia32-libs
share improve this answer
 
2  
damn that installs a lot of stuff. But it works. – Travis R May 1 '12 at 2:43
1  
Like michael, "file" told me it was a 32 bit ELF binary and ldd told me it was not a dynamic executable. Installing these 32 bit libraries fixed the problem. – Eponymous Sep 10 '12 at 19:06
2  
Most misleading error message EVER! o_O – MathematicalOrchid Apr 23 '14 at 16:46
    
re:{Here are the troubleshooting directions from developer.android.com} I don't see any troubleshooting directions there... – ruslo May 18 at 12:58
sudo apt-get install --reinstall libc6-i386

is also need for me.

share improve this answer
 
3  
Did you mean that helped? Any idea why? Where did you get this from? – Tom Wijsman Apr 12 '12 at 15:56

I was also seeing the same after switching my machine from 32 bit ubuntu to 64 bit. Bash would report 'No such file or directory' of files that clearly existed with the execute attribute.

sudo apt-get install --reinstall libc6-i386

Fixed the problem. These are the "GNU C Library: 32-bit shared libraries for AMD64"

Seems like this is a bug in bash. Note that I also changed the default shell from dash to bash using

sudo dpkg-reconfigure dash

before I tried running the 32 bit executable. So I'm not sure if the problem would have happened with the default dash shell

share improve this answer
 

On a fresh Xubuntu 13.10 x64 install I got adb to run with:

sudo apt-get install --reinstall libc6-i386 sudo apt-get install libstdc++6:i386

And also zlib1g:i386 to make aapt work.

and if you still miss something use:

lld adb
share improve this answer
 
    
This worked great for me, but I had to call sudo dpkg --add-architecture i386; sudo apt-get updateto make libstdc++6:i386 available – nicopico Feb 12 '14 at 15:53

For adb make sure you have the SDK unpacked and have run the SDK Manager to fully populate the SDK. Additionally make sure you have the following installed: A.) JDK 6 or better B.) lib32stdc++6 C.) lib32ncurses5

hoffmanc was the closest to getting it right, I don't really understand why the answer from Daniel Beck is marked as correct when it's not even close and has nothing to do with the problem.

Incidentally, if you try to run a truly non-existant command (i.e.:

# fakecommand

you'll get: fakecommand: command not found, whereas in your situation the output you are seeing is actually coming from adb even though it's not very clear that is the case.

share improve this answer
 

Ubunto seems to have some issues with LSB compatibility, so try this if you are on Ubunto

apt-get install lsb

Note that ldd will sort of show that all the libraries are there, but they are not.

usmp-vm-lamp01$ ldd lmgrd linux-vdso.so.1 => (0x00007fffb33fe000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f10b0a48000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f10b074c000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f10b0535000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f10b0175000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f10aff71000) /lib64/ld-lsb-x86-64.so.3 => /lib64/ld-linux-x86-64.so.2 (0x00007f10b0c67000) usmp-vm-lamp01$ locate libpthread.so.0 /lib/x86_64-linux-gnu/libpthread.so.0 usmp-vm-lamp01$ locate libm.so.6 /lib/x86_64-linux-gnu/libm.so.6 usmp-vm-lamp01$ locate /lib64/ld-lsb-x86-64.so.3 usmp-vm-lamp01$
share improve this answer
 
    
I was having this problem with a speech recognition package called Julius. This is what fixed it for me. – Fireandlight27 Oct 16 '14 at 14:16

----------------- -------------------------------------------------

我的操作步驟!

 

702 find / | grep rhel6.1                               找到yum的安裝包目錄 
703 cd /home/mdsoss/rhel6.1_x64               cd 到該目錄 
704 ls
705 cd Packages/                                                                       -----------------------
706 ls                                                                                                        |
707 ls libncurse*                                                                                         |
708 ls *ncurse*                                 |
709 rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm                               |
710 rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm                          |
711 ls                                                                                     -----------------------------無用
712 ls *stdc++*
713 rpm -ivh libstdc++-devel-4.4.5-6.el6.x86_64.rpm
714 rpm -ivh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
715 rpm -ivh libstdc++-4.4.5-6.el6.x86_64.rpm
716 rpm -ivh libstdc++-docs-4.4.5-6.el6.x86_64.rpm                                安裝所有的相關包
717 rpm -ivh libstdc++-4.4.5-6.el6.i686.rpm
718 rpm -ivh libstdc++-devel-4.4.5-6.el6.i686.rpm
719* ls
720 ls *ncurse*
721 rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm
722 rpm -ivh ncurses-libs-5.7-3.20090208.el6.i686.rpm
723 rpm -ivh ncurses-libs-5.7-3.20090208.el6.x86_64.rpm
724 rpm -ivh ncurses-term-5.7-3.20090208.el6.x86_64.rpm                      安裝所有的相關包
725 rpm -ivh ncurses-5.7-3.20090208.el6.x86_64.rpm
726 rpm -ivh ncurses-base-5.7-3.20090208.el6.x86_64.rpm
727 rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
728 rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm
729 ls *zlib*
730 rpm -ivh zlib-1.2.3-25.el6.x86_64.rpm
731 rpm -ivh zlib-1.2.3-25.el6.i686.rpm
732 rpm -ivh zlib-devel-1.2.3-25.el6.i686.rpm
733 rpm -ivh zlib-devel-1.2.3-25.el6.x86_64.rpm                                安裝所有的相關包
734 rpm -ivh jzlib-1.0.7-7.5.el6.x86_64.rpm
735 ls *ia*
736 rpm -ivh yum-plugin-aliases-1.1.30-6.el6.noarch.rpm
737 rpm -ivh libpciaccess-0.10.9-4.el6.x86_64.rpm                        安裝所有的相關包------ia相關包沒找見  安裝pci相關包
738 rpm -ivh libpciaccess-0.10.9-4.el6.i686.rpm
739 ls *libc6*
740 ls *c6*
741 ls *libc*
742 rpm -ivh glibc-2.12-1.25.el6.x86_64.rpm
743 rpm -ivh glibc-devel-2.12-1.25.el6.x86_64.rpm
744 rpm -ivh glibc-2.12-1.25.el6.i686.rpm
745 rpm -ivh glibc-common-2.12-1.25.el6.x86_64.rpm                   安裝libc所有的相關包
746 rpm -ivh glibc-devel-2.12-1.25.el6.x86_64.rpm
747 rpm -ivh glibc-devel-2.12-1.25.el6.i686.rpm
748 rpm -ivh glibc-headers-2.12-1.25.el6.x86_64.rpm
749 rpm -ivh glibc-utils-2.12-1.25.el6.x86_64.rpm
750 yum install glibc-utils
751 ls
752 ls *lsb*
753 rpm -ivh redhat-lsb-4.0-3.el6.x86_64.rpm
754 rpm -ivh redhat-lsb-graphics-4.0-3.el6.x86_64.rpm                   安裝lsb所有的相關包,怕有一些LSB兼容性的問題
755 rpm -ivh redhat-lsb-printing-4.0-3.el6.x86_64.rpm
756 rpm -ivh redhat-lsb-4.0-3.el6.i686.rpm
757 yum install redhat-lsb-4.0-3.el6.i686
758 ls
759 su - wgj1                                                                                   切換到之前的用戶,,一切都變得正常了!!

 

感覺今天有點小成就,又解決了一個問題,積硅步至千里!!!

------------------追更:現在我可能找到了根源,,,之前我在該用戶下使用的是 默認的 bash   ----之后在這個環境下我啟動了 zookeeper和kafka集群  ,,,之后又在該用戶下編譯了公司的代碼,,,修改為csh,,,,,可能當時是這個原因照成上述情況,,,,之后我在該目錄下 安裝了flume  在該用戶的  .bashrc 里邊增加了java的環境變量!后邊執行了  flume 或者 kafka bin下邊的其他依賴java環境的腳本  命令,,,之后報的這個錯,,,建議看完這邊文章的朋友,先檢查一下自己的 shell   看是不是 shell  引起的沖突!!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM