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

OSX crash on startup #4

Closed
sztosz opened this issue Jun 10, 2017 · 12 comments
Closed

OSX crash on startup #4

sztosz opened this issue Jun 10, 2017 · 12 comments

Comments

@sztosz
Copy link

sztosz commented Jun 10, 2017

Failed to start Elixir.
error: {error,{elixir,{"no such file or directory","elixir.app"}}}
[Info  - 11:13:07 PM] Connection to server got closed. Server will restart.
Failed to start Elixir.
error: {error,{elixir,{"no such file or directory","elixir.app"}}}
[Info  - 11:13:08 PM] Connection to server got closed. Server will restart.
Failed to start Elixir.
error: {error,{elixir,{"no such file or directory","elixir.app"}}}
[Info  - 11:13:08 PM] Connection to server got closed. Server will restart.
Failed to start Elixir.
error: {error,{elixir,{"no such file or directory","elixir.app"}}}
[Info  - 11:13:09 PM] Connection to server got closed. Server will restart.
Failed to start Elixir.
error: {error,{elixir,{"no such file or directory","elixir.app"}}}
[Error - 11:13:09 PM] Connection to server got closed. Server will not be restarted.

Right after opening visual code from comandline from elixir, phoenix project path by entering code .

@JakeBecker
Copy link
Owner

This is a bit tricky to debug without being able to reproduce it. ElixirLS is being packaged as an escript, but unlike a typical Elixir escript it doesn't embed Elixir. Instead, there's a shell script that tries to guess where your system Elixir installation is and sets ERL_LIBS to include it before running the escript. This error is happening because it's not setting ERL_LIBS correctly.

Can you help me out by cloning the repository and running build.sh? This should produce a folder elixir-ls-release. Then from that folder try running ./exscript.sh language_server.

If that fails with the same error, would you change the last line of exscript.sh to echo $ERL_LIBS and see what it's setting the variable to? It should match the result of running this command: elixir -e "IO.puts Path.expand(Path.join(Application.app_dir(:elixir), '..'))"

Also, which version of Elixir are you using?

Appreciate the bug report and any help figuring it out. Figuring out how to package ElixirLS has been a real pain.

@sztosz
Copy link
Author

sztosz commented Jun 12, 2017

I'm using asdf for managing elixir versions https://github.com/asdf-vm/asdf. I should have a time in the evening and try to pinpoint what's going on.

@JakeBecker
Copy link
Owner

JakeBecker commented Jun 12, 2017

I just looked into how asdf's Elixir installation works. It sets up your elixir command to run a bash script which runs the executable. The shell script for launching ElixirLS assumes that which elixir yields the actual installation directory, so this is a problem.

I think that as a fallback mechanism, the launcher script might need to run the command elixir -e "IO.puts Path.expand(Path.join(Application.app_dir(:elixir), '..'))" to get Elixir's lib directory. This is a bit slower and doesn't work so well on Windows (because of how Elixir normalizes path separators), but it may be worth implementing if the usual mechanism doesn't work.

@JakeBecker
Copy link
Owner

As a stopgap, you can set your ERL_LIBS manually. On my system, for example, it would be /Users/jakebecker/.kiex/elixirs/elixir-1.4.1/lib/elixir/lib.

@JakeBecker
Copy link
Owner

@sztosz I just updated the launcher script and published v0.0.6. Can you update and let me know if this fixed it? Thanks!

@sztosz
Copy link
Author

sztosz commented Jun 12, 2017

After updating plugin in code

> elixir -v
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.4.4
> code .

No change, same as before.
So then

> export ERL_LIBS=/Users/bartosz/.asdf/installs/elixir/1.4.4/lib
> code .

And I get this what's below.

[Info  - 9:28:39 PM] Child Logger.ErrorHandler of Supervisor Logger.Supervisor started
Pid: #PID<0.77.0>
Start Call: Logger.Watcher.watcher(:error_logger, Logger.ErrorHandler, {true, true, 500})
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:39 PM] Application logger started at :nonode@nohost
[Info  - 9:28:39 PM] Child ElixirLS.LanguageServer.Builder of Supervisor ElixirLanguageServer.Supervisor started
Pid: #PID<0.82.0>
Start Call: ElixirLS.LanguageServer.Builder.start_link(ElixirLS.LanguageServer.Builder)
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:39 PM] Child ElixirLS.LanguageServer.Server of Supervisor ElixirLanguageServer.Supervisor started
Pid: #PID<0.83.0>
Start Call: ElixirLS.LanguageServer.Server.start_link(ElixirLS.LanguageServer.Server)
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:39 PM] Child ElixirLS.IOHandler of Supervisor ElixirLanguageServer.Supervisor started
Pid: #PID<0.84.0>
Start Call: ElixirLS.IOHandler.start_link(ElixirLS.LanguageServer.Server, [name: ElixirLS.LanguageServer.IOHandler])
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:39 PM] Application language_server started at :nonode@nohost
[Info  - 9:28:40 PM] Forcing full rebuild
[Info  - 9:28:42 PM] Application crypto started at :nonode@nohost
[Info  - 9:28:42 PM] Application asn1 started at :nonode@nohost
[Info  - 9:28:42 PM] Application public_key started at :nonode@nohost
[Info  - 9:28:42 PM] Child :ssl_pem_cache of Supervisor :ssl_admin_sup started
Pid: #PID<0.99.0>
Start Call: :ssl_pem_cache.start_link([])
Restart: :permanent
Shutdown: 4000
Type: :worker
[Info  - 9:28:42 PM] Child :ssl_manager of Supervisor :ssl_admin_sup started
Pid: #PID<0.100.0>
Start Call: :ssl_manager.start_link([])
Restart: :permanent
Shutdown: 4000
Type: :worker
[Info  - 9:28:42 PM] Child :ssl_admin_sup of Supervisor :ssl_sup started
Pid: #PID<0.98.0>
Start Call: :ssl_admin_sup.start_link()
Restart: :permanent
Shutdown: 4000
Type: :supervisor
[Info  - 9:28:42 PM] Child :tls_connection of Supervisor :ssl_connection_sup started
Pid: #PID<0.102.0>
Start Call: :tls_connection_sup.start_link()
Restart: :permanent
Shutdown: 4000
Type: :supervisor
[Info  - 9:28:42 PM] Child :tls_socket of Supervisor :ssl_connection_sup started
Pid: #PID<0.103.0>
Start Call: :ssl_listen_tracker_sup.start_link()
Restart: :permanent
Shutdown: 4000
Type: :supervisor
[Info  - 9:28:42 PM] Child :dtls_connection of Supervisor :ssl_connection_sup started
Pid: #PID<0.104.0>
Start Call: :dtls_connection_sup.start_link()
Restart: :permanent
Shutdown: 4000
Type: :supervisor
[Info  - 9:28:42 PM] Child :dtls_udp_listener of Supervisor :ssl_connection_sup started
Pid: #PID<0.105.0>
Start Call: :dtls_udp_sup.start_link()
Restart: :permanent
Shutdown: 4000
Type: :supervisor
[Info  - 9:28:42 PM] Child :ssl_connection_sup of Supervisor :ssl_sup started
Pid: #PID<0.101.0>
Start Call: :ssl_connection_sup.start_link()
Restart: :permanent
Shutdown: 4000
Type: :supervisor
[Info  - 9:28:42 PM] Application ssl started at :nonode@nohost
[Info  - 9:28:43 PM] Child :ftp_sup of Supervisor :inets_sup started
Pid: #PID<0.110.0>
Start Call: :ftp_sup.start_link()
Restart: :permanent
Shutdown: :infinity
Type: :supervisor
[Info  - 9:28:43 PM] Child :httpc_manager of Supervisor :httpc_profile_sup started
Pid: #PID<0.113.0>
Start Call: :httpc_manager.start_link(:default, :only_session_cookies, :inets)
Restart: :permanent
Shutdown: 4000
Type: :worker
[Info  - 9:28:43 PM] Child :httpc_profile_sup of Supervisor :httpc_sup started
Pid: #PID<0.112.0>
Start Call: :httpc_profile_sup.start_link([httpc: {:default, :only_session_cookies}])
Restart: :permanent
Shutdown: :infinity
Type: :supervisor
[Info  - 9:28:43 PM] Child :httpc_handler_sup of Supervisor :httpc_sup started
Pid: #PID<0.114.0>
Start Call: :httpc_handler_sup.start_link()
Restart: :permanent
Shutdown: :infinity
Type: :supervisor
[Info  - 9:28:43 PM] Child :httpc_sup of Supervisor :inets_sup started
Pid: #PID<0.111.0>
Start Call: :httpc_sup.start_link([httpc: {:default, :only_session_cookies}])
Restart: :permanent
Shutdown: :infinity
Type: :supervisor
[Info  - 9:28:43 PM] Child :httpd_sup of Supervisor :inets_sup started
Pid: #PID<0.115.0>
Start Call: :httpd_sup.start_link([])
Restart: :permanent
Shutdown: :infinity
Type: :supervisor
[Info  - 9:28:43 PM] Child :tftp_sup of Supervisor :inets_sup started
Pid: #PID<0.116.0>
Start Call: :tftp_sup.start_link([])
Restart: :permanent
Shutdown: :infinity
Type: :supervisor
[Info  - 9:28:43 PM] Application inets started at :nonode@nohost
[Info  - 9:28:43 PM] Child {:httpc, :hex} of Supervisor :httpc_profile_sup started
Pid: #PID<0.120.0>
Start Call: :httpc_manager.start_link(:hex, :only_session_cookies, :inets)
Restart: :permanent
Shutdown: 4000
Type: :worker
[Info  - 9:28:43 PM] Child Hex.State of Supervisor Hex.Supervisor started
Pid: #PID<0.122.0>
Start Call: Hex.State.start_link()
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:43 PM] Child Hex.Parallel of Supervisor Hex.Supervisor started
Pid: #PID<0.123.0>
Start Call: Hex.Parallel.start_link(:hex_fetcher)
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:43 PM] Child Hex.Registry.Server of Supervisor Hex.Supervisor started
Pid: #PID<0.124.0>
Start Call: Hex.Registry.Server.start_link()
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:43 PM] Application hex started at :nonode@nohost
[Info  - 9:28:43 PM] Child :disk_log_sup of Supervisor :kernel_safe_sup started
Pid: #PID<0.130.0>
Start Call: :disk_log_sup.start_link()
Restart: :permanent
Shutdown: 1000
Type: :supervisor
[Info  - 9:28:43 PM] Child :disk_log_server of Supervisor :kernel_safe_sup started
Pid: #PID<0.131.0>
Start Call: :disk_log_server.start_link()
Restart: :permanent
Shutdown: 2000
Type: :worker
[Info  - 9:28:45 PM] Child of Supervisor :inet_gethost_native_sup started
Pid: #PID<0.204.0>
Start Call: :inet_gethost_native.init([])
[Info  - 9:28:45 PM] Child :inet_gethost_native_sup of Supervisor :kernel_safe_sup started
Pid: #PID<0.203.0>
Start Call: :inet_gethost_native.start_link()
Restart: :temporary
Shutdown: 1000
Type: :worker
Unchecked dependencies for environment dev:
* postgrex (Hex package)
  lock mismatch: the dependency is out of date (run "mix deps.get" to fetch locked version)
[Warn  - 9:28:48 PM] Build failed: %Mix.Error{message: "Can't continue due to errors on dependencies", mix: true}
[Error - 9:28:49 PM] Child ElixirLS.LanguageServer.Builder of Supervisor ElixirLanguageServer.Supervisor terminated
** (exit) shutdown: 1
Pid: #PID<0.82.0>
Start Call: ElixirLS.LanguageServer.Builder.start_link(ElixirLS.LanguageServer.Builder)
Restart: :permanent
Shutdown: 5000
Type: :worker
[Error - 9:28:49 PM] Child ElixirLS.LanguageServer.Builder of Supervisor ElixirLanguageServer.Supervisor caused shutdown
** (exit) :reached_max_restart_intensity
Start Call: ElixirLS.LanguageServer.Builder.start_link(ElixirLS.LanguageServer.Builder)
Restart: :permanent
Shutdown: 5000
Type: :worker
[Error - 9:28:49 PM] Child ElixirLS.LanguageServer.Server of Supervisor ElixirLanguageServer.Supervisor shutdown abnormally
** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.Builder, {:build, %{"file:///Users/bartosz/Documents/Elixir/office/lib/office/web/endpoint.ex" => %ElixirLS.LanguageServer.SourceFile{changed_since_compile?: true, path: "lib/office/web/endpoint.ex", text: "defmodule Office.Web.Endpoint do\n  use Phoenix.Endpoint, otp_app: :office\n\n  socket \"/socket\", Office.Web.UserSocket\n\n  # Serve at \"/\" the static files from \"priv/static\" directory.\n  #\n  # You should set gzip to true if you are running phoenix.digest\n  # when deploying your static files in production.\n  plug Plug.Static,\n    at: \"/\", from: :office, gzip: false,\n    only: ~w(css fonts images js favicon.ico robots.txt)\n\n  # Code reloading can be explicitly enabled under the\n  # :code_reloader configuration of your endpoint.\n  if code_reloading? do\n    socket \"/phoenix/live_reload/socket\", Phoenix.LiveReloader.Socket\n    plug Phoenix.LiveReloader\n    plug Phoenix.CodeReloader\n  end\n\n  plug Plug.RequestId\n  plug Plug.Logger\n\n  plug Plug.Parsers,\n    parsers: [:urlencoded, :multipart, :json],\n    pass: [\"*/*\"],\n    json_decoder: Poison\n\n  plug Plug.MethodOverride\n  plug Plug.Head\n\n  # The session will be stored in the cookie and signed,\n  # this means its contents can be read but not tampered with.\n  # Set :encryption_salt if you would also like to encrypt it.\n  plug Plug.Session,\n    store: :cookie,\n    key: \"_office_key\",\n    signing_salt: \"/bais1Kq\"\n\n  plug Office.Web.Router\nend\n", version: 1}}}, :infinity)
    ** (EXIT) shutdown: 1
Pid: #PID<0.83.0>
Start Call: ElixirLS.LanguageServer.Server.start_link(ElixirLS.LanguageServer.Server)
Restart: :permanent
Shutdown: 5000
Type: :worker
[Info  - 9:28:51 PM] Connection to server got closed. Server will restart.
[Info  - 9:28:52 PM] Child Logger.ErrorHandler of Supervisor Logger.Supervisor started

It repeats itself until

Start Call: ElixirLS.LanguageServer.Server.start_link(ElixirLS.LanguageServer.Server)
Restart: :permanent
Shutdown: 5000
Type: :worker
[Error - 9:29:28 PM] Connection to server got closed. Server will not be restarted.

And it stops here.

One thing that got me curious is that you got path like this: /.kiex/elixirs/elixir-1.4.1/lib/elixir/lib
but in mine /.asdf/installs/elixir/1.4.4/lib there is subfolder elixir, but there isn't another lib in there, only ebin.

Also elixir -e "IO.puts Path.expand(Path.join(Application.app_dir(:elixir), '..'))" gives me /Users/bartosz/.asdf/installs/elixir/1.4.4/lib

Building plugin gives me this

> ./build.sh
src/extension.ts(7,23): error TS2307: Cannot find module 'path'.
src/extension.ts(9,57): error TS2307: Cannot find module 'vscode'.
src/extension.ts(10,101): error TS2307: Cannot find module 'vscode-languageclient'.
src/extension.ts(11,26): error TS2307: Cannot find module 'os'.
test/extension.test.ts(7,25): error TS2307: Cannot find module 'assert'.
test/extension.test.ts(11,25): error TS2307: Cannot find module 'vscode'.
test/extension.test.ts(15,1): error TS2304: Cannot find name 'suite'.
test/extension.test.ts(18,2): error TS2304: Cannot find name 'test'.
test/index.ts(13,18): error TS2304: Cannot find name 'require'.
test/index.ts(22,1): error TS2304: Cannot find name 'module'.
Building ElixirLS submodule
Running dependency resolution...
Dependency resolution completed:
  poison 3.1.0
Generated escript ../../release/language_server with MIX_ENV=dev
Generated escript ../../release/debugger with MIX_ENV=dev
Copy results into elixir-ls-release

But running it obviously fails due to the my elixir through asdf not working with this REL_DIR="$(dirname $(readlink_f $(which elixir)))/../lib"

> ./exscript.sh language_server
Failed to start Elixir.
error: {error,{elixir,{"no such file or directory","elixir.app"}}}

@NobbZ
Copy link

NobbZ commented Aug 25, 2017

I had similar issues on my ubuntu linux box where I do use asdf as well.

Since asdf-elixir does a binary install per default, I forced a src install from git: asdf install elixir ref:v1.4.4

Then there are a lot of *.ex files in ~/.asdf/installs/elixir/ref-v1.4.4/lib/elixir/lib/, and even better, it seems to not crash anymore. Independant of which elixir I actually activate for the current working dir or if ERL_LIBS is set or not. But I think, we still need to observe how this works exactly...

Still, I think there should be a way to specify exact elixir executable and folders to use in the users/workspace config.

@sztosz
Copy link
Author

sztosz commented Aug 25, 2017

I installed through asdf elixir from sources asdf install elixir ref:v1.5.1 And i don't see no more errors.

Though I get auto-completion, I don't think I know how to turn on showing documentation on hover or go-to definition :/

Anyway, no more errors 👍

/cc @NobbZ

@NobbZ
Copy link

NobbZ commented Aug 25, 2017

Haven't checked for docs as well. Wasn't aware of them should be visible. Won't be back at my ubuntu box before monday and my funtoo box at home just worked ever since ;) (there I can use systems elixir)

@JakeBecker
Copy link
Owner

I just published v0.2.4 which should launch more reliably. Please give it a try and let me know if this is still a problem.

@fuelen
Copy link

fuelen commented Oct 28, 2017

I don't know if my problem is related to this, but now I got these errors with invalid path (/Users/jakebecker/)

** (Mix.Config.LoadError) could not load config config/dev.exs
    ** (ArgumentError) argument error
    (stdlib) :erl_eval.expr/3
    (elixir) src/elixir.erl:239: :elixir.eval_forms/4
    (elixir) lib/code.ex:176: Code.eval_string/3
    (mix) lib/mix/config.ex:180: Mix.Config.read!/2
    (mix) lib/mix/config.ex:217: anonymous fn/3 in Mix.Config.read_wildcard!/2
    (elixir) lib/enum.ex:1811: Enum."-reduce/3-lists^foldl/2-0-"/3
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
[Error - 12:39:33] Process #PID<0.112.0> raised an exception
** (Mix.Config.LoadError) could not load config config/dev.exs
    ** (ArgumentError) argument error
    (stdlib) :erl_eval.expr/3
    (elixir) src/elixir.erl:239: :elixir.eval_forms/4
    (elixir) lib/code.ex:176: Code.eval_string/3
    (mix) lib/mix/config.ex:180: Mix.Config.read!/2
    (mix) lib/mix/config.ex:217: anonymous fn/3 in Mix.Config.read_wildcard!/2
    (elixir) lib/enum.ex:1811: Enum."-reduce/3-lists^foldl/2-0-"/3
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
[Error - 12:43:39] Request textDocument/hover failed.
  Message: Internal error: an exception was raised:
    ** (CompileError) /Users/jakebecker/code/elixir/vscode-elixir-ls/elixir-ls/deps/elixir_sense/lib/elixir_sense/core/ast.ex:16: module Ecto.Schema is not loaded and could not be found
        (elixir) src/elixir_expand.erl:86: :elixir_expand.expand/2
        (elixir) src/elixir_expand.erl:511: :elixir_expand.expand_block/4
        (elixir) src/elixir_expand.erl:39: :elixir_expand.expand/2
        (elixir) src/elixir.erl:272: :elixir.quoted_to_erl/3
        (elixir) src/elixir.erl:230: :elixir.eval_forms/4
        (elixir) lib/code.ex:170: Code.eval_string/3
        (elixir_sense) lib/elixir_sense/core/ast.ex:62: ElixirSense.Core.Ast.add_directive_modules_to_env/3
  Code: -32603 
[Error - 12:43:39] Process #PID<0.115.0> raised an exception
** (CompileError) /Users/jakebecker/code/elixir/vscode-elixir-ls/elixir-ls/deps/elixir_sense/lib/elixir_sense/core/ast.ex:16: module Ecto.Schema is not loaded and could not be found
    (elixir) src/elixir_expand.erl:86: :elixir_expand.expand/2
    (elixir) src/elixir_expand.erl:511: :elixir_expand.expand_block/4
    (elixir) src/elixir_expand.erl:39: :elixir_expand.expand/2
    (elixir) src/elixir.erl:272: :elixir.quoted_to_erl/3
    (elixir) src/elixir.erl:230: :elixir.eval_forms/4
    (elixir) lib/code.ex:170: Code.eval_string/3
    (elixir_sense) lib/elixir_sense/core/ast.ex:62: ElixirSense.Core.Ast.add_directive_modules_to_env/3```

@JakeBecker
Copy link
Owner

Ah. Those errors are annoying, but they're happening in the textDocument/hover request. Errors in request handlers don't crash the server, but they are irritating because they steal focus. I'm going to assume this is really a dupe of #19.

I think the original issue of launching the server is fixed, and the process of launching the server has changed significantly since this issue was created, so if you still have problems with launching it, please file a new issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants