Unexpected preparation error: Internal Error - runner failed with exit code: 137


I just tried to convert a build from one of our services to 2.0, but I can’t seem to get it working:

It looks to me like the mvn call isn’t even executed.

I tried reproducing the issue in another repository but that new repository doesn’t seem to be whitelisted for 2.0.

If you need more information I’d be happy to provide it, but since it’s a private build I can’t really share many more details.


I am experiencing the same with this build, which is a new, simple Java application. I am also seeing the same with a pre-existing, upgraded Java project.


This is the same problem as this post: Builds getting killed with vague message: `Received signal killed`

It seems like you’re Out Of Memory. Do you know how much RAM your app generally uses from that step?


That could be it. How much RAM is a container allowed to use? I could definitely limit the amount of RAM the JVM uses.

I tried limiting the heap size to 128M (which works fine locally) and now the build fails with the same error message when it tries to restore caches (that don’t exist because I haven’t had a successful build yet)


That’s very odd. I found the build you referenced and it failed in a way I haven’t seen before. I will open a new bug ticket for that.

Your other repository should be whitelisted; can you try a new build and link me to it? It can be in PM for privacy.


For the time being, builds are limited to 4 GB of ram. This is very much a number in the air (likely to be adjusted higher, not lower).

As for limiting Maven memory consumption, this SO thread says a couple of different things:

  1. Passing the -Xmx flag alone to MAVEN_OPTS is insufficient. You also have to pass -XX:MaxPermSize= flag.
  2. Passing the -Xmx flag by MAVEN_OPTS is insufficient for a forked process (which applies to tests, packaging uncertain to me). Instead, you should pass limit memory with -Xmx in pom.xml

That SO thread is almost 7 years old, but we’ve given similar advice for limiting Maven memory use on 1.0.

For Java memory consumption, I’m honestly out of my element. If either of you (or others reading this) have the extra bandwidth to help me recreate this problem with a basic shareable repo, that would be a huge help to exploring this issue and finding possible workarounds and solutions.


I have a basic shareable example here: https://github.com/mhlz/circleci-test

This is a freshly generated Spring Boot application (a widely used Java web framework).

It’s interesting to note that sometimes the error even comes up before any Maven execution: https://circleci.com/gh/mhlz/circleci-test/7

On my local machine just building takes about 60MB of RAM according to Maven and using ulimit to limit the memory to 128MB doesn’t fail the build on my local machine either.


We found the solution. We spent the last few hours researching this and cmd needs to be overwritten. Just append this to your maven image line:

image: maven
cmd: ["/bin/bash"]


I got finally had the time to try this again and it seems to be working with your suggested fix :slight_smile:

Thank you!

closed #12