Local build erroring on tmp file being a directory

I haven’t run my build locally in a while and I’m thus not sure when this happened. I’ve tried clearing out my machine’s tmp file and uninstalling/reinstalling different ways snap->script->snap, but this didn’t seem to effect the error. I’m not sure if there is some other temp file that exists outside my user profile or the /tmp directory, but I’ve not been able to find it.

$ circleci version
0.1.6949+d951526
$ circleci build
Docker image digest: sha256:9ed852a5b7a9a4b38a4c1a59d3a4c3c3138eeae23f60bc9b02510b574d29b1d3
Error: failed to start event processor: failed to compute task config: failed to read config file: read /tmp/local_build_config.yml: is a directory

Edit: for additional information, here is my config.yml

version: 2
jobs:
  build:
    working_directory: ~/App
    parallelism: 2
    shell: /bin/bash --login
    environment:
      RAILS_ENV: test
      RACK_ENV: test
    docker:
      - image: circleci/ruby:2.5.1-browsers
        environment:
          RAILS_ENV: test
          DB_HOST: localhost
          REDIS_HOST: 127.0.0.1
      - image: circleci/mysql:5.6.37-ram
        command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci --innodb-large-prefix=true --innodb-file-format=Barracuda --sort-buffer-size=67108864
      - image: redis

    steps:
      # Machine Setup
      # If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
      # The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
      - checkout
      # Restore the dependency cache
      - restore_cache:
          keys:
          # This branch if available
          - v1-dep-{{ .Branch }}-
          # Default branch if not
          - v1-dep-master-
          # Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
          - v1-dep-
      - run:
          name: Bundle Install
          command: |-
            bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
      # The following line was run implicitly in your 1.0 builds based on what CircleCI inferred about the structure of your project. In 2.0 you need to be explicit about which commands should be run. In some cases you can discard inferred commands if they are not relevant to your project.
      # Save dependency cache
      - save_cache:
          key: v1-dep-{{ .Branch }}-{{ epoch }}
          paths:
          - vendor/bundle
          - ~/.bundle
          - ~/.cache/bower
      - run:
          name: Generate config/database.yml
          command: |-
            mkdir -p config && echo 'test:
              adapter: mysql2
              database: circle_test
              username: root
              host: 127.0.0.1
              encoding: utf8mb4
              collation: utf8mb4_general_ci
            ' > config/database.yml
      - run:
          name: Generate config/secrets.yml
          command: |-
            echo "test:
                 Things go here
            " > config/secrets.yml
      - run:
          name: Create / Migrate Database
          command: |-
            bundle exec rake db:create db:migrate --trace

      # GPG version 1 is needed because version 2 no longer really allows for passing the password to encrypt on the command line.
      - run: sudo apt-get update

      # TEST_FILES is broken out into it's own variable because of random bash parsing issues which case "bundler: failed to load command: rspec"
      - run:
          name: Rspec Unit Tests
          no_output_timeout: "20m"
          command: |-
            bundle exec rspec --require spec_helper --format RspecJunitFormatter --out /tmp/circle-tests/rspec/rspec.xml --format progress $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
      # Teardown
      #   If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
      # Save test results
      - store_test_results:
          path: /tmp/circle-tests
      # Save artifacts - these are viewable in the Artifacts tab of the CircleCI interface after a build is complete
      - store_artifacts:
          path: /tmp/circle-tests

This doesn’t seem to be project related, I’ve tried running circleci build in other project directories and the result is the same.

@Fir3Chi3f was you able to fix this? I have the same issue, ubuntu 20.04

Nope, I actually just ran into it again today with a different project having completely forgotten about it.

circleci version 0.1.8599+d6e83e7 (snap) circleci local execute --job build -e DOCKER_USERNAME={redacted} -e DOCKER_PASSWORD={redacted} -e PACKAGIST_KEY={redacted}
Docker image digest: sha256:caa46f16bcfa31143fa19c2ba9a2ad747cabba1b06eaac52020e191ee11f85b6
Error: failed to start event processor: failed to compute task config: failed to read config file: read /tmp/local_build_config.yml: is a directory

1 Like

I am facing the same issue even with the circleci demo repo.

Ubuntu 18.04.2
Docker 19.03
circleci 0.1.8764+bb7188b

After searching a lot I found this answer which helps me to solve this issue. Following the instructions I remove the snap docker and installed as indicated here then went into the demo project of circleci and executed the local execute command, and worked fine.

This isn’t really the solution—it’s a workaround that probably works because you ended up installing a different version of Docker that behaves differently. What’s really happening is circleci local is attempting to mount a non-existent file on your host machine; since the file doesn’t exist, some versions of Docker will interpret that non-existent source path in a volume mount request as intending to mount a directory, therefore the destination in the container will be an empty directory. So CircleCI CLI is not creating that source file in time before the docker run that uses it for volume mount.

I’ve found where that is in CircleCI source FWIW… It’s in local/local.go:295.

Tracking ticket for this bug is here: Running `cirlceci local execute` inside a container fails · Issue #413 · CircleCI-Public/circleci-cli · GitHub. Check out my latest comment on there for a workaround I came up with that doesn’t require changing versions of Docker.

@zeke I was looking at that line 295 and I noticed something much more basic

There is no call to “close” the file after the call to “WriteString()”

So the data is probably not on disk or available to another process
Also, depending on the permissions on the open for the reader and writer processes involved there might be permission problems for the process doing the reading.

Perhaps the reason all the playing around with the different versions of docker only works because some delay gets introduced which allows the creator of the file to trigger a “flush” operation before the reader is instantiated and able to read the contents.

Update: I cloned the repo and rebuilt with a call to “Close()”. This did not change the result so my comment above is not the cause - though I think a Close() would be appropriate.

After much investigation, I have confirmed that it’s a “Docker in Docker” type issue related to the filesystem’s capabilities (probably only related to the various Windows implementations of the VM solution: Docker Tool Kit, WSL1, WSL2, & Hypervisor) I reproduced the issue without circleci components.

At present I’m attempting to create the initial launch as a shell script rather than a container and thus avoiding the container-in-container problems related to the FS

Hi @anthonyscolaro! I have the same issue. Did you get a workaround?

Do not use snap! Install CircleCI with brew.