You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@parcel/transformer-elm does not resolve a compiler for linux_arm64 architectures, and fails when building projects.
🤔 Expected Behavior
Can resolve the correct compiler for linux_arm64 architectures.
😯 Current Behavior
Returns a failure message which has nothing to do with the underlying issue when running parcel in any configuration that uses @parcel/transformer-elm to compile Elm programs.
The actual message that shows up in the console is a JSON parsing error and not indicative of the actual underlying issue:
No number after minus sign in JSON at position 1 (line 1 column 2)
This comes from the following line in the code found in ElmTransformer.js:
try{code=awaitcompileToString(_nodeElmCompiler().default,elmBinary,sources,compilerConfig);}catch(e){letcompilerJson=e.message.split('\n')[1];letcompilerDiagnostics=JSON.parse(compilerJson);// *<--- Error that is surfaced
The error that we care however is the the e variable. Printing that out shows that actual problem:
-- ERROR -----------------------------------------------------------------------
I am detecting that your computer (linux_arm64) may not be compatible with any
of the official pre-built binaries.
I recommend against using the npm installer for your situation. Check out the
alternative installers at https://github.com/elm/compiler/releases/tag/0.19.1
to see if there is something that will work better for you.
From there I recommend asking for guidance on Slack or Discourse to find someone
who can help with your specific situation.
--------------------------------------------------------------------------------
Clearly this output is not JSON and thus the reason for the JSON parsing error.
💁 Possible Solution
It is best practice to install the elm binary directly on your system, the official approach from the Elm docs is to use a command like the following:
# Elm
RUN curl -sS -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz \
&& gunzip elm.gz \
&& chmod +x elm \
&& mv elm /usr/local/bin
Quite often, this is how folks install and use Elm. The elm binary that is used via @parcel/transformer-elm is a convenience but mostly redundant in systems where Elm already is setup. Certainly in this case.
The official setup as demonstrated above already produces a compatible Elm binary to use in linux_arm64 environments, such as linux containers run on Mac's.
It would make sense to be able to use an env variable that when present would be used as the compiler binary that @parcel/transformer-elm resolves.
It would work similar to the PARCEL_ELM_NO_DEBUG flag functionality that currently exists.
In the resolveLocalElmBinary function, implemented naively:
functionresolveLocalElmBinary(options){try{if(options.env.PARCEL_ELM_BINARY)returnoptions.env.PARCEL_ELM_BINARY// <-- PROPOSEDletresult=require.resolve('elm/package.json');// $FlowFixMeletpkg=require('elm/package.json');letbin=nullthrows(pkg.bin);// <-- currentreturnpath.join(path.dirname(result),typeofbin==='string' ? bin : bin.elm,);}catch(_){returnnull;}}
🔦 Context
It took a lot of debugging to find the underlying issue I was facing due to the actual cause that was being overshadowed by a JSON parsing error.
💻 Code Sample
For the following elm programs
module Main exposing (main)
import Html exposing (text)
main =
text "Hello, Parcel!"
Run the following command:
pnpm parcel build ./src/Main.elm --no-cache
🌍 Your Environment
Software
Version(s)
Parcel
2.13.2
Node
22.14.0
pnpm
10.5.1
Operating System
Darwin
Docker
27.5.1
Container
python:3.12.9-slim-bookworm
Container arch
linux_arm64
The text was updated successfully, but these errors were encountered:
🐛 bug report
@parcel/transformer-elm does not resolve a compiler for linux_arm64 architectures, and fails when building projects.
🤔 Expected Behavior
Can resolve the correct compiler for linux_arm64 architectures.
😯 Current Behavior
Returns a failure message which has nothing to do with the underlying issue when running parcel in any configuration that uses @parcel/transformer-elm to compile Elm programs.
The actual message that shows up in the console is a JSON parsing error and not indicative of the actual underlying issue:
No number after minus sign in JSON at position 1 (line 1 column 2)
This comes from the following line in the code found in
ElmTransformer.js
:The error that we care however is the the
e
variable. Printing that out shows that actual problem:Clearly this output is not JSON and thus the reason for the JSON parsing error.
💁 Possible Solution
It is best practice to install the elm binary directly on your system, the official approach from the Elm docs is to use a command like the following:
Quite often, this is how folks install and use Elm. The elm binary that is used via
@parcel/transformer-elm
is a convenience but mostly redundant in systems where Elm already is setup. Certainly in this case.The official setup as demonstrated above already produces a compatible Elm binary to use in linux_arm64 environments, such as linux containers run on Mac's.
It would make sense to be able to use an env variable that when present would be used as the compiler binary that
@parcel/transformer-elm resolves
.It would work similar to the
PARCEL_ELM_NO_DEBUG
flag functionality that currently exists.In the
resolveLocalElmBinary
function, implemented naively:🔦 Context
It took a lot of debugging to find the underlying issue I was facing due to the actual cause that was being overshadowed by a JSON parsing error.
💻 Code Sample
For the following elm programs
module Main exposing (main) import Html exposing (text) main = text "Hello, Parcel!"
Run the following command:
🌍 Your Environment
The text was updated successfully, but these errors were encountered: