Programing

"해당 파일 또는 디렉토리가 없습니다"이지만 존재합니다.

lottogame 2020. 10. 17. 09:00
반응형

"해당 파일 또는 디렉토리가 없습니다"이지만 존재합니다.


명령 줄에서 실행 파일을 실행하고 ./arm-mingw32ce-g++싶지만 오류 메시지가 나타납니다.

bash: ./arm-mingw32ce-g++: No such file or directory

Ubuntu Linux 10.10을 실행하고 있습니다. ls -l기울기

-rwxr-xr-x 1 root root  433308 2010-10-16 21:32 arm-mingw32ce-g++

sudo ( sudo ./arm-mingw32ce-g++)를 사용하면

sudo: unable to execute ./arm-mingw32ce-g++: No such file or directory

OS가 파일이있을 때 파일을 볼 수없는 이유를 모르겠습니다. 이견있는 사람?


이 오류는 ./arm-mingw32ce-g++존재하지 않음 (하지만 존재 함) 또는 존재하고 커널에서 인식하지만 동적 로더를 사용할 수없는 동적으로 연결된 실행 파일임을 의미 할 수 있습니다. 다음을 실행하여 필요한 동적 로더를 확인할 수 있습니다 ldd /arm-mingw32ce-g++. 표시된 not found것은 설치해야하는 동적 로더 또는 라이브러리입니다.

amd64 설치에서 32 비트 바이너리를 실행하려는 경우 :


Ubuntu에서 Selenium 소스를 빌드하려고 할 때이 오류가 발생했습니다. 올바른 shebang이있는 간단한 쉘 스크립트는 모든 전제 조건을 다룬 후에도 실행할 수 없었습니다.

file file-name # helped me in understanding that CRLF ending were present in the file.

Vim에서 파일을 열었을 때 Windows 시스템에서이 파일을 편집했기 때문에 DOS 형식이라는 것을 알 수있었습니다. 아래 명령을 사용하여 파일을 Unix 형식으로 변환했습니다.

dos2unix filename # actually helped me and things were fine.

플랫폼간에 파일을 편집 할 때마다 파일 형식도주의해야합니다.


이 오류는 스크립트를 실행하려고하는데 shebang의 철자가 틀린 경우에도 발생할 수 있습니다 . 확인이 읽고 #!/bin/sh, #!/bin/bash또는 당신이 사용하고있는 중 통역.


Python 스크립트를 실행하려고 할 때 동일한 오류 메시지가 표시되었습니다. 이것은 @Warpspace의 의도 된 사용 사례가 아니었지만 (다른 주석 참조) 내 검색에서 가장 많이 검색된 항목 중 하나이므로 누군가 유용하게 사용할 수 있습니다.

제 경우 에는 shebang 라인 ( )이 넘어가 는 것은 DOS 라인 엔딩 ( \r\n대신)이었습니다 . 간단하게 고쳤습니다.\n#!/usr/bin/env pythondos2unix myfile.py


32/64 비트 문제가없는 간단한 bash 스크립트에 대해 동일한 오류가 발생했습니다. 실행하려는 스크립트에 오류가 있기 때문일 수 있습니다. 우분투 포럼 게시물 은 일반 스크립트 파일에서 'sh'를 앞에 추가 할 수 있으며 일부 디버그 출력을 얻을 수 있음을 나타냅니다. 예 :

$ sudo sh arm-mingw32ce-g++

출력이 있는지 확인합니다.

제 경우 실제 문제는 실행하려는 파일이 Linux가 아닌 Windows 형식이라는 것입니다.


아래 명령은 16.4 Ubuntu에서 작동했습니다.

이 문제는 .sh 파일이 손상되었거나 유닉스 프로토콜에 따라 형식이 지정되지 않은 경우 발생합니다.

dos2unix는 .sh 파일을 Unix 형식으로 변환합니다!

sudo apt-get install dos2unix -y
dos2unix test.sh
sudo chmod u+x test.sh 
sudo ./test.sh

이 오류가 발생 “No such file or directory”했지만 내 파일이 Windows에서 생성되었고 Ubuntu에서 실행하려고했고 파일에 새 줄이있는 곳에 잘못된 15 \ r가 포함되어 있기 때문에 존재합니다. 원치 않는 내용을 잘라내는 새 파일을 방금 만들었습니다.

sleep: invalid time interval ‘15\r’
Try 'sleep --help' for more information.
script.sh: 5: script.sh: /opt/ag/cont: not found
script.sh: 6: script.sh: /opt/ag/cont: not found
root@Ubuntu14:/home/abc12/Desktop# vi script.sh 
root@Ubuntu14:/home/abc12/Desktop# od -c script.sh 
0000000   #   !   /   u   s   r   /   b   i   n   /   e   n   v       b
0000020   a   s   h  \r  \n   w   g   e   t       h   t   t   p   :   /

0000400   :   4   1   2   0   /  \r  \n
0000410
root@Ubuntu14:/home/abc12/Desktop# tr -d \\015 < script.sh > script.sh.fixed
root@Ubuntu14:/home/abc12/Desktop# od -c script.sh.fixed 
0000000   #   !   /   u   s   r   /   b   i   n   /   e   n   v       b
0000020   a   s   h  \n   w   g   e   t       h   t   t   p   :   /   /

0000400   /  \n
0000402
root@Ubuntu14:/home/abc12/Desktop# sh -x script.sh.fixed 

Mac에서 만든 파일과 동일한 문제가 발생했습니다. ./filename을 사용하여 쉘에서 실행하려고하면 파일을 찾을 수 없음 오류 메시지가 나타납니다. 파일에 문제가있는 것 같습니다.

내가 한 것:

서버에 SSH 세션을 열고
고양이 파일 이름은
클립 보드에 출력을 복사
rm 파일 이름의
터치 파일 이름
VI 이름
난 삽입 모드에 대한
클립 보드의 내용 붙여
모드 삽입 끝에 ESC를
: WQ를!

이것은 나를 위해 일했습니다.


I just had this issue in mingw32 bash. I had execuded node/npm from Program Files (x86)\nodejs and then moved them into disabled directory (essentially removing them from path). I also had Program Files\nodejs (ie. 64bit version) in path, but only after the x86 version. After restarting the bash shell, the 64bit version of npm could be found. node worked correctly all the time (checked with node -v that changed when x86 version was moved).

I think bash -r would've worked instead of restarting bash: https://unix.stackexchange.com/a/5610


As mentioned by others, this is because the loader can't be found, not your executable file. Unfortunately the message is not clear enough.

You can fix it by changing the loader that your executable uses, see my thorough answer in this other question: Multiple glibc libraries on a single host

Basically you have to find which loader it's trying to use:

$ readelf -l arm-mingw32ce-g++ | grep interpreter
  [Requesting program interpreter: /lib/ld-linux.so.2]

Then find the right path for an equivalent loader, and change your executable to use the loader from the path that it really is:

$ ./patchelf --set-interpreter /path/to/newglibc/ld-linux.so.2 arm-mingw32ce-g++

You will probably need to set the path of the includes too, you will know if you want it or not after you try to run it. See all the details in that other thread.


I had this issue and the reason was EOL in some editors such as Notepad++. You can check it in Edit menu/EOL conversion. Unix(LF) should be selected. I hope it would be useful.

참고URL : https://stackoverflow.com/questions/3949161/no-such-file-or-directory-but-it-exists

반응형