/bin/sh: mkdir: command not found


I’ve started migrating my Circle config to 2.0 but I can’t test it, because the build fails on the type: checkout step with the above error. The complete output is like this:

set -e && mkdir -p ~/.ssh && echo '
github.com ssh-rsa blablablabla
bitbucket.org ssh-rsa blablablabla
' >> ~/.ssh/known_hosts && (umask 077; touch ~/.ssh/id_rsa) && chmod 0600 ~/.ssh/id_rsa && (cat <<EOF > ~/.ssh/id_rsa
) && mkdir -p /Account && cd /Account && git clone $CIRCLE_REPOSITORY_URL . && git fetch --force origin circle-2.0:remotes/origin/circle-2.0 && git reset --hard $CIRCLE_SHA1 && git checkout -q -B $CIRCLE_BRANCH && git reset --hard $CIRCLE_SHA1
/bin/sh: mkdir: command not found
Exited with code 127

/bin/sh is aliased to /bin/bash in a pre-checkout step I added in an attempt to mitigate the issue like this:

- type: shell
  pwd: /
  shell: /bin/bash --login
  command: |
    rm /bin/sh
    ln -s /bin/bash /bin/sh
    which /bin/sh
    which /bin/bash

No dice, however. What’s gone wrong?


version: 2
executorType: docker
  - image: mono:4.2.4
      - NODE_ENV=production
      - TERM=xterm-color
      - YARN_VERSION=0.17.8
      - PATH="${PATH}:${HOME}/.yarn/bin"

    workDir: /MyProject
      - type: shell
        pwd: /
        shell: /bin/bash --login
        command: |
          rm /bin/sh
          ln -s /bin/bash /bin/sh
          echo $HOME
          ls -alh /bin
          which /bin/sh
          which /bin/bash
          echo $PATH

      - type: checkout    # Fails here

It’s worth noting that Mono uses Ubuntu as it’s base image. I’ve tried Mono, Ubuntu and even Alpine to no avail.


I’m not sure that rm /bin/sh is safe. Just to confirm, you were having a problem before doing that, yes?

Could you share a link to where you’re seeing this?


I figured it out! It seems 2.0 doesn’t (yet?) support variable interpolation in containerInfo:env fields. My path was being set to literally ${PATH}:${HOME}/.yarn/bin. I found some other workarounds for this and removed that env setting which seems to work.

Will variable interpolation be supported in the future? It’s a really useful feature.


@anon30319619 do you have any insight into this question?


@jamwaffles In the future it should be supported, but for now you will need to export it manually:

export PATH="$PATH:~/.yarn/bin"


I’m getting a similar error when I try to build an elixir project (trying to follow the example: Getting Started: Elixir)

The error:
set -e && mkdir -p ~/.ssh && echo ' github.com ssh-rsa xoxoxoox bitbucket.org ssh-rsa xixixixiix ' >> ~/.ssh/known_hosts && (umask 077; touch ~/.ssh/id_rsa) && chmod 0600 ~/.ssh/id_rsa && (cat <<EOF > ~/.ssh/id_rsa $CHECKOUT_KEY EOF ) && mkdir -p /home/ubuntu/test && cd /home/ubuntu/test && git clone $CIRCLE_REPOSITORY_URL . && git fetch --force origin e2e_tests:remotes/origin/e2e_tests && git reset --hard $CIRCLE_SHA1 && git checkout -q -B $CIRCLE_BRANCH && git reset --hard $CIRCLE_SHA1
/bin/sh: 1: mkdir: not found Exited with code 127



@cpanato Can you provide us with a link to that build? The error could be a red herring. Are you modifying your PATH earlier in your circle.yml?



this is one

and this I tried to create the workdir before


The problem is your PATH:

PATH: “$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH”

You will need to export that manually. We do not currently evaluate the contents of that string you’re setting it to; it’s being set verbatim. Adding it to step with export will solve your problem.


thanks so much it works!



You’ll probably have to run that export at the top of every command that needs access to asdf or the resulting shims. If you’re running CircleCI 2.0 for Elixir or Erlang, I would recommend that until the interpolation is properly supported you use the Erlang and Elixir binary packages from Erlang solutions. I’m currently running an Ubuntu image and use the following to install those:

      - type: shell
        name: Update Package Cache
        command: |
          apt-get update
      - type: shell
        name: Install Package Dependencies
        command: |
          apt-get -y install curl
      - type: shell
        name: Install Erlang & Elixir
        command: |
          curl -o /tmp/erlang-solutions_1.0_all.deb https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
          dpkg -i /tmp/erlang-solutions_1.0_all.deb
          apt-get update
          apt-get -y install \
            erlang=1:19.2-1 \

Getting Started: Elixir

Cool, thanks @DavidAntaramian

do you cache this? because take a lot of time to install that. :frowning:



I change the docker base image to ubuntu and in the checkout step now fail because is missing git

link to the project: https://circleci.com/gh/meltwater/animal/216

any advise?

set -e && mkdir -p ~/.ssh && echo ' github.com ssh-rsa xoxoxo bitbucket.org ssh-rsa xoxoxox ' >> ~/.ssh/known_hosts && (umask 077; touch ~/.ssh/id_rsa) && chmod 0600 ~/.ssh/id_rsa && (cat <<EOF > ~/.ssh/id_rsa $CHECKOUT_KEY EOF ) && mkdir -p /home/ubuntu/animal && cd /home/ubuntu/animal && git clone $CIRCLE_REPOSITORY_URL . && git fetch --force origin e2e_tests:remotes/origin/e2e_tests && git reset --hard $CIRCLE_SHA1 && git checkout -q -B $CIRCLE_BRANCH && git reset --hard $CIRCLE_SHA1
/bin/sh: 7: git: not found Exited with code 127


I don’t. I’m not sure what Circle does on their side, but I think they have an intermediary cache for packages because it only takes 1m07s to fetch and install the binaries. That’s a pretty small period of time in my opinion. Especially considering on CircleCI 2.0 most of my tests complete in less than 3 minutes.


To further my response, you can also follow the instructions here to create your own Docker image to use for testing: Frequently Asked Questions

This is getting slightly off topic from the original poster’s issue, though, so may be best to split this off into your own thread :slight_smile:


Git is likely not installed. Most images are very minimal, so many don’t include git. I have been pulling those images, adding git, removing the apt cache files, and pushing it under my own Docker hub account.


ok, I understood