Compiler: Point to "how to make CI fast" link when cache is messed up

Created on 17 Nov 2018  Â·  8Comments  Â·  Source: elm/compiler

When running elm make with an elm-stuff directory but no ~/.elm directory the build fails with an error about corrupt binaries:

$ elm make src/**/*.elm
Success! Compiled 1 module.
-- CORRUPT BINARY -- /Users/mbark/.elm/0.19.0/package/elm/browser/1.0.0/objs.dat

The binary data at /Users/mbark/.elm/0.19.0/package/elm/browser/1.0.0/objs.dat
is corrupt.

Elm caches build artifacts in the following directories:

    /Users/mbark/.elm
    elm-stuff/

Maybe you recently installed a command line tool or editor plugin that messes
with them? They definitely should not be doing that, but you never know! So
maybe try deleting them? Everything will be rebuilt from scratch. This may help
reveal the corrupting influence.

SSCCE

I was able to reproduce the error consistently with the elm-todomvc with elm installed via Homebrew:

$ git clone https://github.com/evancz/elm-todomvc.git
$ cd elm-todomvc
$ elm make src/**/*.elm
$ rm -rf ~/.elm
$ elm make src/**/*.elm
Success! Compiled 1 module.
-- CORRUPT BINARY -- /Users/mbark/.elm/0.19.0/package/elm/browser/1.0.0/objs.dat
[...]

Workaround

Our current workaround for this problem to remove the ~/.elm and elm-stuff directories before running elm make when doing a production build (as this happens every time we try to do a build in our CI environment otherwise).

Most helpful comment

@evancz The error message could clearly be better. The word "corrupt" could be replaced with "corrupt or missing" and it would be a vast improvement.

All 8 comments

How is your ~/.elm directory getting deleted?

I've seen this too, from naïvely running elm make in a docker container with the host machine's source directory mounted into it. In this case the ~/.elm directory appears to elm make to be missing, while the elm-stuff (which is seen inside the container) persists across invocations.

That may not be a reasonable thing to do, though it worked perfectly with 0.18. At the very least, the error message here is confusing, and stymied me for a while: even printing "missing" instead of "corrupt" in this specific case would be a win.

The typical case where this happens is in our CI environment which is setup to start in a clean environment (i.e. no ~/.elm directory) and then downloads a pre-built elm-stuff directory from our Artifactory server (since it doesn't have internet access due to security reasons) and finally tries to run elm make.

I just realized that with Elm 0.19 we should now store the ~/.elm directory (rather than elm-stuff) in Artifactory instead, which makes this issue not really occur very often. However, as @purcell says the error message is a bit confusing and could maybe be clarified?

Yeah, you want to store ~/.elm instead with 0.19. I would recommend not storing elm-stuff/, and only looking into it if you think it'll save enough time that is worth the risk of messing with cached artifacts and timestamps.

I think it'd be good to add a link to a documenting how to get fast builds on CI when people are getting this kind of error though. I'm not convinced things should work different at this time though.

FYI this just tripped me up trying to get stated with Elm on GitLab. I was following this example which is broken (at least in part) due to this issue. See my comment on the example for work arounds.

A couple of (GitLab specific) updates:

  1. I opened a PR to add an example Elm app to their GitLab pages repo (comments there are welcome because I am an Elm newbie), but:
  2. I confirmed that trying to use their caching with ~/.elm and elm-stuff results in CORRUPT BINARY on subsequent builds 😞

@evancz The error message could clearly be better. The word "corrupt" could be replaced with "corrupt or missing" and it would be a vast improvement.

Was this page helpful?
0 / 5 - 0 ratings