Skip to content

Expert goes looking for Elixir in a fresh PATH in a fresh shell, but my dev environment can't work that way #299

@kivikakk

Description

@kivikakk

Hiya! This is my third time giving Expert a time; each time I've had a different show-stopper.

Today we get further than ever before, but bring-up fails at:

...
23:16:37.752 [info] Child :net_kernel of Supervisor :net_sup started
Pid: #PID<0.186.0>
Start Call: :net_kernel.start_link(%{name: :"expert-manager-kv-20199@127.0.0.1", supervisor: :net_sup_
dynamic, net_tickintensity: 4, net_ticktime: 60, name_domain: :longnames, clean_halt: false})
Restart: :permanent
Shutdown: 2000
Type: :worker
23:16:37.753 [debug] Child :net_sup_dynamic of Supervisor :kernel_sup started
Pid: #PID<0.183.0>
Start Call: :erl_distribution.start_link(%{name: :"expert-manager-kv-20199@127.0.0.1", supervisor: :ne
t_sup_dynamic, net_tickintensity: 4, net_ticktime: 60, name_domain: :longnames, clean_halt: false})
Restart: :permanent
Shutdown: 1000
Type: :supervisor
23:16:37.779 [debug] sent notification server -> client window/logMessage
23:16:37.780 [error] Failed to find an elixir executable, shutting down
23:16:37.780 [debug] sent notification server -> client $/progress
23:16:37.784 [error] Process #PID<0.182.0> terminating
** (exit) :ok
    (stdlib 6.2.2.2) gen_server.erl:2210: :gen_server.init_it/6
    (stdlib 6.2.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

Reading the source, it turns out Expert tries to launch a new shell without a PATH variable set, navigate to the project directory, and then look for elixir in PATH:

defp path_env_at_directory(directory, shell) do
# We run a shell in interactive mode to populate the PATH with the right value
# at the project root. Otherwise, we either can't find an elixir executable,
# we use the wrong version if the user uses a version manager like asdf/mise,
# or we get an incomplete PATH not including erl or any other version manager
# managed programs.
env = [
# Disable shell session history to reduce noise
{"SHELL_SESSIONS_DISABLE", "1"},
# Start with a clean PATH to get the correct new value
{"PATH", nil}
]

I use Nix and dev shells (nix develop) to manage my toolchains. This will never find an elixir executable, since I don't (and won't ever) have one setup outside a dev shell. Indeed, the correct elixir executable is the one that was already on PATH, because I'm in a dev shell when I start my editor! This is how my other LSPs manage to find their tools.

Can we perhaps fall back to an elixir found on the PATH in Expert's environment itself if this method doesn't produce anything?

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