circleci-cli: local execute - fails to read config file

Context

I’m working on a CircleCI config generator (amongst other things) so I want to test that:

  • the generated config is valid (circleci config validate)
  • the generated tests pass (circleci local execute --job myjob)

From within CircleCI, so essentially I’m running those CircleCI commands in CircleCI. Very meta but it sounds like it should work. First command (config validation) works fine.

Problem

I get the following error when running circleci local execute --job myjob (within a CircleCI job):

$ circleci local execute --job myjob
Docker image digest: sha256:0ae15d9b8329446dd5d241b1d654774871caa89c1cc47d513063c23037aae917
Error: failed to start event processor: failed to compute task config: failed to read config file: open circle.yml: no such file or directory

It’s confusing because I’m using .circleci/config.yml and not using circle.yml. The same command runs fine locally.

Running version 0.1.4211+14dfd68

What I tried

  • Using the --config argument ❌
  • Moving the generated code outside of the generator repo (to avoid git conflicts or even multiple circle ci config files in parent directories) ❌
  • Running chmod 777 .circleci/config.yml

Here’s the smallest generator config file I’ve been able to reproduce teh bug with: https://gist.github.com/n6g7/f11008ee351b3dfd9c56f6c23b5ce7d6, I don’t think the generated config file matters but can share it too if necessary.

Any idea where this could be coming from?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 18 (6 by maintainers)

Most upvoted comments

@jgonzalezd

experiencing this issue after installing circleci with snap as by instructions and trying to run the hello world example.

➜  circleci-demo-go git:(master) circleci local execute --job build
Docker image digest: sha256:02289762fd0a295b971e4bc6bdb2ea4326a66748cae89352b5404c4ca286aaf9
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

this could be connected with limitations of snap packages to the $HOME directory, as it is trying to write/read a files save in the root /tmp/ while circleci can only run in /usr/home/<user-name>

SOLUTION TO FIX THE ISSUE

Remove snap packages (docker and snap)

sudo snap remove circleci docker

I used the command from the quick installation instructions without sudo and saved the bin file in my /home/<username>/Downloads folder

curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | DESTDIR=/home/fabrizio/Downloads bash

then I moved the binary sudo mv /home/fabrizio/circleci /usr/local/bin, /usr/local/bin is in my path so I have access within the $HOME as normal user.

Installing docker as by askubuntu instructions (options 2), adding myself to the docker group and now the command works without problems

circleci was failing because snap installation can not write or read /tmp It was fun playing with Ubuntu the entire day…

I’m running into the same issue, it doesn’t even work for the demo repo.

circleci-demo-go$ circleci local execute --job build
Docker image digest: sha256:2e3d8ff7707b34b815fc6174ae5f6fcd8384f7a166a219bad29ac5ffc139f475
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

@fabriziobertoglio1987 I can’t run the quick installation command without sudo. When I try to run it I get this error:

$ curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | DESTDIR=/home/zach/Downloads bash
Starting installation.
Installing CircleCI CLI v0.1.15085
Installing to /home/zach/Downloads
An error occured installing the tool.
The contents of the directory /tmp/tmp.1O5TPuzqUN have been left in place to help to debug the issue.

Trying to get CircleCI working locally circleci local execute. This works (and is simpler IMO 👍 )

  1. Run Docker in Docker with git tag (so CircleCI CLI can use git command within the container)
    • /usr/bin/docker run --rm --privileged --tty --interactive --volume /tmp:/tmp:rw --volume /var/run/docker.sock:/var/run/docker.sock:ro --user root --name circleci docker:git /bin/sh
    • Notice flags --privileged, volume for docker.sock and a rw mount of local /tmp.
    • Running container as --user=root
  2. Once inside the container, install bash, curl followed by CircleCI CLI.
    • /sbin/apk update
    • /sbin/apk add bash curl
    • /usr/bin/curl -fLSs https://circle.ci/cli | /bin/bash
  3. For a simple hello world example using CircleCI CLI (within the container, of course)
    • Create a foo_ci project (like this)
    • Create a .circleci/config.yml (like this)
    • Run a CircleCI job locally (like this). Have fun!
Downloading latest CircleCI build agent...
Docker image digest: sha256:f19e1f3d0aadb3dedfeb147b8e603fbbe7a9afba924b0db0c43f74753002c96b
====>> Spin up environment
Build-agent version  ()
System information:
 Server Version: 20.10.11
 Storage Driver: overlay2
  Backing Filesystem: extfs
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Kernel Version: 4.19.232-1.ph3-esx
 Operating System: VMware Photon OS/Linux
 OSType: linux
 Architecture: x86_64

Starting container cimg/ruby:3.0-node
Warning: No authentication provided, using CircleCI credentials for pulls from Docker Hub.
  image is cached as cimg/ruby:3.0-node, but refreshing...
3.0-node: Pulling from cimg/ruby
Digest: sha256:22ef54404f4676b4f329fc7e0537d32b016e2120bdabb47c191f184d5a4aa56f
Status: Image is up to date for cimg/ruby:3.0-node
cimg/ruby:3.0-node:
  using image cimg/ruby@sha256:22ef54404f4676b4f329fc7e0537d32b016e2120bdabb47c191f184d5a4aa56f
  pull stats: Image was already available so the image was not pulled
  time to create container: 437ms
Creating Docker containers in parallel
Time to upload agent and config: 1.112579856s
Time to start containers: 1.090775188s
====>> Preparing environment variables
Using build environment variables:
  BASH_ENV=/tmp/.bash_env-localbuild-1648434504
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=
  CIRCLE_BUILD_NUM=
  CIRCLE_JOB=build
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_REPOSITORY_URL=
  CIRCLE_SHA1=
  CIRCLE_SHELL_ENV=/tmp/.bash_env-localbuild-1648434504
  CIRCLE_WORKING_DIRECTORY=~/project


The redacted variables listed above will be masked in run step output.====>> Checkout code
Making checkout directory "/home/circleci/project"
Copying files from "/tmp/_circleci_local_build_repo" to "/home/circleci/project"
====>> echo "Hello World"
  #!/bin/bash -eo pipefail
echo "Hello World"
Hello World
Success!

Works for below errors-

  1. circleci Error: failed to start event processor: failed to compute task config: failed to read config file: (👍 Step 1)
  2. cp: cannot stat '/tmp/_circleci_local_build_repo/.git': No such file or directory (👍 Try step 3 on a hello world project)

@anishkny A workaround for running a CircleCI config generated inside of a CircleCI job is to commit that config and push it to Github/Bitbucket to trigger a new build. This is far from ideal, so we are considering ways to execute a new config without a commit and push.

I am facing a similar issue trying to run a generated config yml using circleci local execute in CircleCI.

In my test, I generate a processed.yml (running on CircleCI) and then execute:

circleci local execute --config /home/circleci/project/test/tmp.H4nOfY/processed.yml

But I get an error:

Downloading latest CircleCI build agent...
Docker image digest: sha256:...^@^@Error: failed to start event processor: failed to compute task config: failed to read config file: open /home/circleci/project/test/tmp.H4nOfY/processed.yml: no such file or directory
Exited with code 1

Is there a workaround for this?

@zmunro run those steps one by one in your terminal, you will be able to read and troubleshoot the error.