Windows find no such file or directory

Решаем ошибку error no such file or directory

Ошибка error no such file or directory (Ошибка: нет файла или каталога) возникает на различных устройствах и программах. Разберем возможные решения в некоторых случаях.

В любом случае, в первую очередь обратите внимание на наличие необходимого файла или папки, если он указан в ошибке.

Если ошибка возникает при запуске приложения и после появления ошибки загрузка прекращается, происходет «вылет», вероятно игра или приложение установлена с ошибкой, либо в установочном файле отсутствуют важные компоненты. Если файлы скачаны через торент, проверьте целостность ХЭШа. Для этого кликните на закачку правой кнопкой и нажмите «Пересчитать хэш».

Проверьте, соответствует ли разрядность вашей операционной и запускаемого приложения. К примеру, ошибка no such file or directory появится, если вы запускаете программу, предназначенную для 64-х битных систем в 86-битной Windows.

Так же проверьте, есть ли у выполняемой программы или скрипты все необходимые права на чтение и запись. В windows запустите программу от имени администратора.

При написании программ и скриптов обратите внимание на кириллические символы в пути к файлу или папке.

Эта статья очень обобщенная, но вы наверняка пришли с конкретной ошибкой. Просим вас внести свой вклад в сообщество и напишите свою ошибку error no such file or directory и название программы, в которой она возникает в комментариях ниже. Мы постараемся вам помочь.

find command in bash script resulting in “No such file or directory” error only for directories?

UPDATE 2014-03-21

So I realized I wasn’t as efficient as I could be, as all the disks that I needed to «scrub» were under /media and named » disk1 , disk2 , disk3 , etc.» Here’s the final script:

Next will probably to just clean up the code even more, and add features like logging and reporting results (through e-mail or otherwise); excluding system and directories; and allowing people to customize the list of files/directories.

Thanks for all the help!

UPDATE

Before I incorporated the helpful suggestions provided by everyone, I performed some tests, the results of which were very interesting (see below).

As a test, I ran this command:

The results (which is what I expected):

However, when I ran the actual command (without echo ):

I received the same «error» output:

I put «error» in quotes because obviously the folder was removed, as verified by immediately running:

It seems like the find command stored the original results, acted on it by deleting the directory, but then tried to delete it again? Or is the -f option of rm , which is supposed to be for ignoring nonexistent files and arguments, is ignored? I note that when I run tests with the rm command alone without the find command, everything worked as expected. Thus, directly running rm -rf . \nonexistent_directory , no errors were returned even though the «non_existent_directory» was not there, and directly running rm -r \nonexistent_directory provided the expected:

Читайте также:  Windows 7 usb dvd download tool linux

Should I use the -delete option instead of the -exec rm . option? I had wanted to make the script as broadly applicable as possible for systems that didn’t have -delete option for find .

Lastly, I don’t presume it matters if /media/disk1 , /media/disk2 , . are combined in an AUFS filesystem under /media/storage as the find command is operating on the individual disks themselves? Thanks for all the help so far, guys. I’ll publish the script when I’m done.

ORIGINAL POST

I’m writing a bash script to delete a few OS X remnants on my Lubuntu file shares. However, when executing this:

I see the following output:

find: /media/disk1/Pictures/.AppleDouble : No such file or directory

Before I added the -exec rm . portion the script found the /media/disk1/Pictures/.AppleDouble directory. The script works properly for removing DS_Store files, but what am I missing for the find command for directories?

I’m afraid to screw too much with the -exec portion as I don’t want to obliterate directories in error.

find: `./folder’: No such file or directory

This is the contents of the directory I’m working with:

Now I would like to remove everything from this directory except for the file demo.c . Here’s the command I’ve come up with:

It does exactly what you’d think it would do (meaning, the file test and the directory folder are gone), but at the same time it also displays the following error message:

Why do you think that is?

3 Answers 3

it also displays this error message:

Because find recognizes ./folder as a directory when it first reads directory . , before considering whether it matches the find criteria or performing any action on it. It does not recognize that the action will remove that directory, so after performing the action, it attempts to descend into that directory to scan its contents. By the time it does that, however, the directory no longer exists.

There are multiple ways to address the problem. One not yet mentioned is to use the -prune action. This tells find not to descend into directories that match the tests:

That will serve nicely here, and it also has applications in areas where you are not deleting the directory and you do not want to limit the search depth.

Additionally, another way to avoid affecting . would be to make use of the fact that find accepts multiple base paths to test, that these can designate regular files if you wish, and that during pathname expansion any leading . in a filename must be matched explicitly. If, as in your case, there are no dotfiles in the target directory (other than . and .. ), then you can accomplish your objective like this:

System error: no such file or directory on Windows #2301

Comments

atrauzzi commented Oct 31, 2015

Trying to run docker-compose up , my first container with a bind mount seems to be failing:

Here’s the relevant portion of my docker-compose.yaml :

Docker Compose version:

Docker Machine version:

Other fun facts:

  • Windows 10
  • Project runs fine on OSX and Linux
  • docker-machine ssh default and it looks like all the vboxsf mounts are good
  • Containers seem to be building fine, phewf!
  • cc. #1085
  • cc. #2158
  • cc. #2128
  • Apologies if it seems like this is a duplicate, I haven’t seen any momentum on getting this resolved and hopefully I’m not being dramatic when I say: This is quite a blocker and I’d love to be able to continue helping with testing my real project on Windows.
Читайте также:  Неисправность windows код 10

The text was updated successfully, but these errors were encountered:

dnephin commented Nov 2, 2015

A docker inspect for the container would be really helpful to debug this.

giboow commented Nov 5, 2015

@atrauzzi Where are you’re shared volumes? in C:\Users ?

atrauzzi commented Nov 5, 2015

Yeah, in a path under my home dir.

atrauzzi commented Nov 6, 2015

dnephin commented Nov 6, 2015

Ok, the bind mounts look correct.

I looked around for tickets with similar errors, and I’m pretty sure the issue is with the entrypoint script /docker-entrypoint.sh . The script needs to have executable permission ( chmod +x ).

I’m not sure how that works in windows. I don’t think there is an equivalent. So I think you’ll have to change your config to include:

That way the script isn’t being run directly, it’ll run using bash, which has the executable permission enabled on it already.

rebsp commented Nov 10, 2015

I ran into the same problem, the entrypoint addition didn’t help with my enviroment though.
Tried bind mounts with relative and absolute paths, no difference.
Environment: Windows 7 Pro, runs fine under Linux and OSX as well
Docker version 1.9.0, build 76d6bc9
docker-compose version: 1.5.0
docker-machine.exe version 0.5.0 (04cfa58)
Edit: gist of inspect

dnephin commented Nov 10, 2015

@rebsp that inspect shows no entrypoint and a Cmd of /start_up.sh .

I don’t think the issue has to do with volumes, it’s an issue with file permissions. In linux you have to give a file executable permission before you can run it. I don’t know how to give it that permission from windows.

Can you try with a command: [«bash», «/start_up.sh»] ? and if that doesn’t work a gist of the inspect and the error message you get

dnephin commented Nov 10, 2015

@chadzink yours sounds like a different issue, I took a quick look at the inspect, but I don’t see anything wrong. You might need to open a new issue about it.

chadzink commented Nov 10, 2015

@dnephin Thanks for looking, I’ll do that.

rebsp commented Nov 10, 2015

@dnephin thanks for looking into it, I totally pasted the wrong inspect, sorry about that! Here are the two relevant inspects, once with command: [«bash», «/start_up.sh»] and once with entrypoint: [‘bash’, ‘/docker-entrypoint.sh’] :

dnephin commented Nov 10, 2015

I notice the «Error»: «», line doesn’t have the same [8] System error: no such file or directory error from the original issue.

From what I can see, the error is coming from start_up.sh . If you add set -x to that script, maybe it will give you more output about the failure?

rebsp commented Nov 10, 2015

Jep, it just says
/start_up.sh: line 4: /var/www/html/src/htdocs/wp-content: No such file or directory

So the directory doesn’t seem to exist on the docker machine? On my Windows host it’s clearly there.

dnephin commented Nov 10, 2015

The mounts in the inspect look to be at D:\foo . Have you created a virtualbox shared folder for that path? docker-machine only shares C:\Users by default.

I don’t think your issue is related to this one.

jamescarlos commented Nov 19, 2015

I had a similar issue with Windows 10 and changing the following in my Dockerfile worked for me:

CMD [«/run.sh»]
to
ENTRYPOINT [«/bin/bash», «/run.sh»]

mimischi commented Dec 2, 2015

Wow thanks @dnephin and @jamescarlos! I’m using Cookiecutter-Django (https://github.com/pydanny/cookiecutter-django) and stumbled on this problem on Windows 7. Putting «/bin/bash» in front of the entrypoint-file resolved this issue!

dnephin commented Mar 7, 2016

atrauzzi commented Apr 3, 2016

@dnephin — I’m actually starting to wonder if this ticket has something to do with the paths that compose is sending in for the bind mounts.

Читайте также:  Что это код ошибки 0xc004c003 windows 10 как исправить

I just tried starting up a project today and got this error. My VM does have the windows filesystem mounted, but if I’m using relative paths, where is compose telling the VM-docker daemon to start in order to find the files?

dnephin commented Apr 4, 2016

Compose doesn’t communicate with the VM. docker-machine adds a single shared folder for /C/Users , and nothing else is available by default.

atrauzzi commented Apr 21, 2016

I think it’s safe to close this. Bind mounts seem to be working on Windows using the docker beta, so I’d say so long as the docker ecosystem manages to translate paths to VM mounts correctly, there’s no problem here.

nilyang commented Nov 1, 2016 •

panic: standard_init_linux.go:175: exec user process caused «no such file or directory»

I have been encountered this error every time on my Windows 10 when I run this command :

docker build -t my:hello .
docker run -ti my:hello bash

FROM debian:jessie
VOLUME [«/data»]
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s /usr/local/bin/docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT [«/bin/sh», «/docker-entrypoint.sh»]

That’s all . I hope some one can help my problem.

seanWebster10GRP commented Aug 8, 2017

Sets git to clone repos without adjusting line-endings for unix to windows

For anyone coming across this issue. This was one of the first places I checked for a solution for this as I was experiencing the same problem when running Docker CE for windows. After some extensive research and multiple attempts, I came across this, which is the only fix that has worked for me so far. It may not resolve your issues, but it is something to try first at least.

Windows ends lines in a carriage return and a linefeed \r\n ,
While Linux and macOS only use a linefeed \n .

In cmd enter: git config —global core.autocrlf input

vipatron commented Apr 29, 2019

@dnephin: You have ended days of headache for me. Thank you. I inherited a project that seemed to be built for UNIX, and no Mac or Linux user knew the answer.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Ошибка FileNotFoundError: [Errno 2] No such file or directory

Командная строка выдает ошибку FileNotFoundError: [Errno 2] No such file or directory , подробнее на скрине (столкнулся с такой проблемой, изучая учебник Лутца по Python и не могу сдвинуться в изучении языка из-за этого)

Буду признателен за помощь.

1 ответ 1

Есть различные способы задать путь к файлу или папке:

c:\python370\script1.py — абсолютный путь

script1.py — относительный путь, задается относительно текущей рабочей директории. В данном случае файл должен находиться в текущей директории.

В вашем случае текущая директория C:\Users\Acer , вы пытаетесь открыть файл script1.py , но он у вас находится не в этой директории, а в c:\python370 . Поэтому просто по имени файла вы файл не откроете, нужно указать полный (абсолютный) путь:

Или запускать Python сразу из нужной директории — двойным кликом по файлу python.exe в папке c:\python370 или в окне cmd сначала перейти в директорию, где лежит нужный файл, потом запустить python, и пробовать открыть файл.

C:\Users\Михаил — это текущая директория.

Меняем текущую директорию такой командой (опять же в cmd, до запуска python):

В python текущую директорию можно узнать, выполнив команды:

cwd — сокращение от current working directory — текущая рабочая директория.

Поменять текущую директорию из Python можно так:

В итоге, если текущая рабочая директория не совпадает с директорией, где лежит файл, то вы не сможете открыть файл просто по его имени. Нужно или указать полный (абсолютный) путь, или изменить текущую директорию.

Кстати, чтобы не экранировать обратные слеши в строке пути, можно использовать «сырые» (raw) строки, с буквой r перед кавычками, например:

Оцените статью