# Mkdir doesn't work correctly

**URL:** <https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174>\
**Category:** Deployments\
**Created:** [September 16, 2018, 8:14pm UTC](https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174 "2018-09-16T20:14:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xshenk](https://avatars.discourse-cdn.com/v4/letter/0/c67d28/32.png) [@0xshenk](https://discuss.circleci.com/u/0xshenk)\
**Post date:** [September 16, 2018, 8:14pm UTC](https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174/1 "2018-09-16T20:14:44Z")

</div>

I have tons of issues with mkdir all the time.

I have this line in my config.yml:

```
  - run:
      name: Save Docker image layer cache
      command: |
        mkdir -p caches
        docker save -o /caches/app.tar app

```

It worked fine for a long time but suddenly I am seeing this:

```
failed to save image: unable to validate output path: directory "/caches" does not exist
Exited with code 1

```

Why isn’t mkdir -p caches working?

I had the same problem with mkdir -p test-results/coverage test-results/nose  
The directories wouldn’t be found with mkdir and I ended up having to just put a .gitkeep in those folders.

But /caches/ did work until recently. Overall I really don’t get why mkdir doesn’t seem to actually create directories.

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [September 16, 2018, 9:11pm UTC](https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174/2 "2018-09-16T21:11:20Z")

</div>

> [@0xshenk](#):
>
> mkdir -p caches

I suspect your command is being run relative to the default build folder, and this is not the FS root (`/`). Try swapping this to `mkdir -p /caches`.

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [September 16, 2018, 9:23pm UTC](https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174/3 "2018-09-16T21:23:32Z")

</div>

Also if you are going to try to make a folder under `/` (root) then you might run into a permissions issue so you should do it as `sudo`.

---

<div class="post-metadata">

**Author:** ![0xshenk](https://avatars.discourse-cdn.com/v4/letter/0/c67d28/32.png) [@0xshenk](https://discuss.circleci.com/u/0xshenk)\
**Post date:** [September 16, 2018, 9:26pm UTC](https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174/4 "2018-09-16T21:26:49Z")

</div>

I’ll try that. But it was working fine before for a while the way it is now. Not sure why suddenly it isn’t. I have the same problem with the test results directories. Although they had the issue from the start.

Makes no sense to me why it wouldn’t work. Hopefully your suggestion fixes it even if it doesn’t explain why it worked fine until now

---

<div class="post-metadata">

**Author:** ![Cormac](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cormac/32/18955_2.png) [@Cormac](https://discuss.circleci.com/u/Cormac)\
**Post date:** [September 18, 2018, 12:45am UTC](https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174/5 "2018-09-18T00:45:48Z")

</div>

Was `working_directory` set to `/` at any point, by any chance? It could also be a change to the image – if you go back to the last time it succeeded, under “spin up containers” you should be able to view the sha256 digest of the image. You can then pin this by specifying (for example):

`- image: circleci/ruby@sha256:afbbf67e01be90e59a9d838175f320b8187fa477aed98dadb53688d8d80dbff1`

See whether this changes the behaviour, and that may help you to find out why this changed initially.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [December 17, 2018, 12:45am UTC](https://discuss.circleci.com/t/mkdir-doesnt-work-correctly/25174/6 "2018-12-17T00:45:57Z")

</div>

Closed on December 17, 2018, 12:45am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
