Skip to content

Engine is compiled with system Erlang, despite using Mise (MacOS, fish) #275

@katafrakt

Description

@katafrakt

OS: MacOS Tahoe
Editor: Emacs / eglot
Shell: fish
Expert version: built from git
Version manager: mise

This is probably very niche, but Expert stopped working for me today at all. Whenever it tries to start, after compiling the engine it fails with something like:

3:06:42.859 [debug] Node port message: 
13:06:42.851 [error] beam/beam_load.c(150): Error loading module 'Elixir.XPForge.NodePortMapper':
  corrupt atom table



13:06:42.865 [debug] Node port message: 
13:06:42.865 [error] beam/beam_load.c(150): Error loading module 'Elixir.XPForge.EPMD':
  corrupt atom table

Even worse, now when I try to do anything in my project, I'm getting similar error with Error loading module 'Elixir.Hex. Every time, I need to mix local.hex --force.

After some digging I found that when engine building does it's own mix local.hex --force, it does that in Elixir 1.19.4-otp27 directory, but using Erlang/OTP 28 installed from Homebrew. Even further down the line, I found that Expert.Port when detecting fish, in path_Env_at_directory, starts a new fish shell using fish -l -c, which modifies the path. This is probably because -l reevaluates fish config, runs eval "$(/opt/homebrew/bin/brew shellenv)" from ~/.config/fish/conf.d/env.fish` (I believe this is autogenerated by Homebrew, as I don't recall creating this file).

As a result, the beginning of path when I run echo $PATH in my shell:

/Users/pawel.sw/.opam/4.14.0/bin /Users/pawel.sw/Downloads/google-cloud-sdk/bin /Users/pawel.sw/.local/share/mise/installs/elixir/1.19.4-otp-27/bin

but when I log the path in Expert.Port, after path_env_in_directory, it is:

/opt/homebrew/bin:/opt/homebrew/sbin:/Users/pawel.sw/.local/bin:/Users/pawel.sw/dev/lexical/_build/dev/package/lexical/bin

The directories are in a completely different order, and indeed, erl now points to the Homebrew installation.

The issue also manifests in log file with this message:

12:43:20.143 [debug] Building engine: * creating /Users/pawel.sw/.local/share/mise/installs/elixir/1.19.4-otp-27/.mix/archives/hex-2.3.1-otp-28

12:43:20.673 [debug] Building engine: * creating /Users/pawel.sw/.local/share/mise/installs/elixir/1.19.4-otp-27/.mix/elixir/1-19-otp-28/rebar3 

(OTP 28 in OTP 27 directory)

Solution

After trying out few things I found that changing this line into ["--no-config", "-c", cmd] fixes the issue. The PATH is now inherited from parent process and correct Erlang version (from mise) is picked. It looks to me like a safe change to make, but I wanted to discuss this first, because I don't know the whole history behind the PATH handling here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions