mstalker

mstalker

Parallel compiler cannot find files sometimes

I’m getting an intermittent compilation error when building a project in Docker:

== Compilation error in file lib/sentry/logger.ex ==
** (MatchError) no match of right hand side value: {:error, :enoent}
    (elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
could not compile dependency :sentry, "mix compile" failed. You can recompile this dependency with "mix deps.compile sentry", update it with "mix deps.update sentry" or clean it with "mix deps.clean sentry"

Kernel.ParallelCompiler.spawn_workers/6 calls :elixir_compiler.file/2, which calls file:read_file/1, which returns {error, enoent} if it can’t find a file.

:elixir_compiler.file/2 tries to pattern-match…

{ok, Bin} = file:read_file(File)

…fails, and raises the MatchError we see above.

Here are a few thoughts:

  • I could just do what the instructions tell me to do :slight_smile: …and recompile the dependency with mix deps.compile sentry, but this only happens intermittently, so I don’t think the problem is with how I’m compiling. This is part of an automated build, too, and recompiling one dependency occasionally isn’t ideal.
  • I’m using the most recent version of Sentry, so mix deps.update sentry won’t help.
  • I don’t think mix deps.clean sentry is the answer because I’m starting off with a clean slate; I’m building the project while building a Docker image. Both deps/ and _build/ are in my .dockerignore file.
  • This only seems to happen with the Sentry library.
  • The issue is intermittent. On most attempts to build the project and the Docker image, everything compiles correctly.
  • Even though the error was in lib/sentry/logger.ex in the code snippet above, this error sometimes springs up in other files in the Sentry library.
  • My Docker image is running Erlang/OTP 20, and Elixir 1.6.1 compiled with OTP 20, on Debian GNU/Linux 8.

Do you have any suggestions for how to debug this? I’m a bit flummoxed. There’s an existing issue on the Sentry project that describes the problem, but I thought it might actually be a bug in the Elixir compiler, so I posted here, just in case :smile:

Most Liked

easco

easco

Are you seeing the problem on a Mac?

Using my mix project and docker files (which are unrelated to Sentry) on both an Mac and on our Linux-based build server, I’ve seen similar compile problems “frequently” when running in the dev environment on my Mac laptop, but never when running the container on the build server. The Mac often finishes without error - but will fail once out of 4 or 5 times.

I suspect that it may be related to the synchronization and timing between the Macintosh file system, and the container’s virtual file system. You may choose to read https://docs.docker.com/docker-for-mac/osxfs/#performance-issues-solutions-and-roadmap

But please understand that this is just a suspicion on my part - I have no verifiable evidence to prove or disprove.

josevalim

josevalim

Creator of Elixir

One idea is to use strace at the moment of compilation and trace all of the system calls happening on lib/sentry/logger.ex. Something like:

$ mix deps.get
$ enable strace on deps/sentry
$ mix deps.compile
$ disable strace
$ mix compile

For all purposes, it seems the file exists in disk. So we need to figure out if for some reasons docker is saying it does not. In case docker does say it exists and Erlang still says it doesn’t, then there is something else at play.

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New

We're in Beta

About us Mission Statement