So let me try to detail the problem a little bit more. I have a source code repository locally with the appropriate CircleCI 2.0 YAML file in the repository. The way I’m running the local build with CircleCI currently is:
circleci-builder build -v $(pwd):/opt/app
This mounts the local directory to
/opt/app which is also the working directory declared by the
The problem is that my local source code repository is set up for local testing against my computer. For example, the default configuration files utilize environment variables. Locally, I have configuration files (that are excluded from git) that overrides the default configuration; for example, I have one that specifies the test database as
postgres://localhost/app_test. But the CircleCI build has a different PostgreSQL database setup, and it expects to pass it via environment variable. But that environment variable is being shadowed by my local configuration file that isn’t expected to be present during Circle runs.
Configuration I can solve in less than elegant ways, but then I also have build artifacts that don’t work because of operating system differences. My local artifacts are compiled for
darwin (macOS), but the CircleCI build will expect
linux (Ubuntu), and the compile system spends some time trying to load files it thinks are already compiled, only to throw them out when it realizes they aren’t compatible.
So in essence, in my mind, it is easier to solve this problem by having the local build clone the repository on the current branch (and thereby excluding all the files in
.gitignore). I’m not sure this is the best way to solve it, but it did throw me for a loop last week while setting up a build. And it makes it difficult for us to allow for both actual local testing and local CircleCI testing.