ydg33

ydg33

Jason fails to compile when MIX_ENV=prod

Hello!

I’m trying to set up a small Elixir app that depends on jason via another package. Using mix release works, but as soon as I set MIX_ENV=prod I get one of the following errors, nondeterministically:

→ MIX_ENV=prod mix release
==> jason
Compiling 10 files (.ex)

== Compilation error in file lib/encode.ex ==
** (SyntaxError) invalid syntax found on lib/encode.ex:318:57:
     error: unexpected token: "\" (column 57, code point U+005C)
     │
 318 │   slash_escapes = Enum.zip(~c"\b\t\n\f\r\\"\\", ~c"btnfr\"\\")
     │                                                         ^
     │
     └─ lib/encode.ex:318:57
    (elixir 1.16.0) lib/kernel/parallel_compiler.ex:428: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8
could not compile dependency :jason, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile jason --force", update it with "mix deps.update jason" or clean it with "mix deps.clean jason"
→ MIX_ENV=prod mix release
==> jason
Compiling 10 files (.ex)

== Compilation error in file lib/decoder.ex ==
** (SyntaxError) invalid syntax found on lib/decoder.ex:825:24:
     error: unexpected token: "\" (column 24, code point U+005C)
     │
 825 │        when byte in ~c"\s\n\r\t" do
     │                        ^
     │
     └─ lib/decoder.ex:825:24
    (elixir 1.16.0) lib/kernel/parallel_compiler.ex:428: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8
could not compile dependency :jason, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile jason --force", update it with "mix deps.update jason" or clean it with "mix deps.clean jason"

I’ve looked at the code in jason and it looks innocuous:

  slash_escapes = Enum.zip(~c"\b\t\n\f\r\\"\\", ~c"btnfr\"\\")

Does MIX_ENV=prod change something about the Elixir language?

Marked As Solved

arcanemachine

arcanemachine

My first step when weird stuff like this happens is to delete the _build directory and try again.

Also, what version of Erlang OTP are you using? Does the error still occur if you use a newer/older version of OTP? How about an older version of Elixir? Which platform are you on? (Linux, Mac, Windows)

Also Liked

sodapopcan

sodapopcan

You will have an improved QOL if you don’t wonder such things :upside_down_face:

ydg33

ydg33

Thanks both for the reply! Sorry for not including the version numbers @hubertlepicki.

Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]
Elixir 1.16.0 (compiled with Erlang/OTP 26)

deps/jason/mix.exs says it’s 1.4.1. I’m on macOS.

However, I tried @arcanemachine’s suggestion of rm -rf _build and bizarrely it worked! Very strange. It’s good to know but I wonder how that situation happened.

Also thanks for the tip about using override: true, will remember that!

arcanemachine

arcanemachine

Glad that helped. I literally had the same thing happen yesterday. (It’s not a common occurrence, but it has happened to me before.)

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
Tee
can someone please explain to me how Enum.reduce works with maps
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
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
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
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability 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
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement