Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS app fails to start Elixir standalone runtime with "no Elixir executable found in PATH" #908

Closed
w0rd-driven opened this issue Jan 21, 2022 · 2 comments
Labels
area:desktop Related to Livebook desktop app bug Something isn't working

Comments

@w0rd-driven
Copy link
Contributor

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 24 [erts-12.0.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit]

Elixir 1.13.2 (compiled with Erlang/OTP 24)
  • Elixir location:
> ~ which elixir
/Users/jbrayton/.asdf/shims/elixir
  • Operating system: macOS Big Sur
  • How have you started Livebook (mix phx.server, livebook CLI, Docker, etc): macOS app
  • Livebook version (use git rev-parse HEAD if running with mix): 0.5.0
  • Browsers that reproduce this bug (the more the merrier): Chrome
  • Include what is logged in the browser console:
[Report Only] Refused to create a worker from 'http://localhost:8080/js/editor.worker.js' because it violates the following Content Security Policy directive: "worker-src 'none'".

This only happens on page load so I don't think it's relevant as nothing is emitted to the console when cleared.

  • Include what is logged to the server console:

Current behavior

  1. Open the Elixir and Livebook notebook.
  2. Click Evaluate under the section Autocompletion to evaluate the hello world Elixir code.
  3. The error message Failed to setup runtime - no Elixir executable found in PATH is emitted.

Expected behavior

"Hello world" is output.

Workarounds tried

  1. Configuring the Runtime settings for Embedded, code like Hello world executes but Mix.install fails with
** (UndefinedFunctionError) function Mix.install/1 is undefined (module Mix is not available)
    Mix.install([kino: "~> 0.5.0"])
  1. Configuring the Runtime settings for Attached node, the rest of the notebook executes as expected.

Summary

I'm pretty sure the cli launches as a current user context but the application seems to only resolve system-wide paths, likely due to Big Sur's sandboxing. The attached node works because I'm executing the elixir process instead of the app.

The function that triggers the error is find_elixir_executable/0 and if I could get System.find_executable("elixir") to return the ASDF shim then I suspect it would function as expected.

I could personally use a system-wide elixir install but it would be beneficial to avoid this if possible.

@josevalim
Copy link
Contributor

Thank you for the report!

We actually want to embed both Elixir and Erlang inside the release/app. Here is the plan:

  1. Embed the release with include_erts: false
  2. Copy Erlang into the release
  3. Copy Elixir into the release
  4. Add both to the path before starting Livebook

Copying Erlang into the release is relatively straight-forward and it is a matter of doing the steps here plus copying all applications in lib.

Copying Elixir there is no recipe but it shouldn't be complicated either. We can also just unpack the precompiled Elixir file.

Both of those steps could be done before invoking the app builder. All the app builder needs to know are the additional paths it needs to add before calling the executable.

@josevalim josevalim added area:desktop Related to Livebook desktop app bug Something isn't working labels Jan 21, 2022
@w0rd-driven
Copy link
Contributor Author

Fixed in #929.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:desktop Related to Livebook desktop app bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants