"PROBLEM BUILDING DEPENDENCIES" error in pipeline (SOLVED)

TLDR; If you are getting some random error from the Elm compiler like the one below, make sure that you are not running two compilations processes at the same time on the same machine for two different projects, as this could be an issue.


Let me move from the Slack chat to here the thread related to an issue (and a resolution), so that it became searchable in case other people face something similar in the future.

At work, we had issues with this type of error during a pipeline of a monorepo hosting several Elm projects:

-- PROBLEM BUILDING DEPENDENCIES -----------------------------

I ran into a compilation error when trying to build the following package:

    fredcy/elm-parseint 2.0.1

This probably means it has package constraints that are too wide. It may be
possible to tweak your elm.json to avoid the root problem as a stopgap. Head
over to https://elm-lang.org/community to get help figuring out how to take this
path!

Note: To help with the root problem, please report this to the package author
along with the following information:

    elm/core 1.0.5

If you want to help out even more, try building the package locally. That should
give you much more specific information about why this package is failing to
build, which will in turn make it easier for the package author to fix it!

The weird thing is that these errors were happening on a random base and they were referencing random packages.

It seems the issue was about a conflict between the Elm caching system and the Nx/Jenkins caching system.

Nx (https://nx.dev/) and Jenkins (https://www.jenkins.io/) are the technologies used in our pipeline and they support the parallel execution of processes.

The Elm compiler caching system works on two separate layers.

One is located in the folder “elm-stuff” inside the project folder. The other is located in the folder “.elm” under the $HOME folder (or $ELM_HOME if defined).

While each Elm project has its own elm-stuff folder, .elm is shared among all the Elm projects on the same machine.

This caused issues when multiple instances of the compiler were running at the same time on the same machine, in parallel.

A resolution was to create an independent .elm folder for each project with

export ELM_HOME=${HOME}/.elm_${PROJECT_NAME}

This has the consequence that the same package is downloaded more than once if used in multiple projects, but this only happens the first time a project is created. After that, the Nx cache should kick in, and only newly added packages should be downloaded.

Any better suggestion is welcome.

I heard that similar issues are happening randomly on Netlify. Not sure what that could be, but it may still be related to some caching conflict. I don’t know if this issue could happen also if several compiler processes are happening at the same time but they belong to the same project, instead of different projects (the monorepo case).

Prior art and references

4 Likes

Thank you so much for investigating this and finding the cause Luca!

I think it’s likely that this is because a lot of elm-pages users use Netlify, but not actually related to Netlify. The elm-pages build command is running two parallel compilation tasks for the client and worker apps:

In the upcoming release this is no longer happening, so that race condition should be avoided. Good to know what was the source of it finally, thanks again for sharing your findings!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.