1

elixir(1.8.1) 和 erlang(21.3.5) 是通过 .tool-versions(ASDF) 文件在本地设置的。

ElixirLS 使用上述版本的 elixir 启动,但需要更高版本

** (UndefinedFunctionError) function ElixirLS.Utils.OutputDevice.get_opts/0 is undefined (module ElixirLS.Utils.OutputDevice is not available)
    ElixirLS.Utils.OutputDevice.get_opts()
    lib/wire_protocol.ex:33: ElixirLS.Utils.WireProtocol.intercept_output/2
    lib/language_server/cli.ex:6: ElixirLS.LanguageServer.CLI.main/0
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir) lib/code.ex:232: Code.eval_string/3
[Info  - 1:09:58 PM] Connection to server got closed. Server will restart.
** (UndefinedFunctionError) function ElixirLS.Utils.OutputDevice.get_opts/0 is undefined (module ElixirLS.Utils.OutputDevice is not available)
    ElixirLS.Utils.OutputDevice.get_opts()
    lib/wire_protocol.ex:33: ElixirLS.Utils.WireProtocol.intercept_output/2
    lib/language_server/cli.ex:6: ElixirLS.LanguageServer.CLI.main/0
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir) lib/code.ex:232: Code.eval_string/3
[Info  - 1:09:59 PM] Connection to server got closed. Server will restart.
** (UndefinedFunctionError) function ElixirLS.Utils.OutputDevice.get_opts/0 is undefined (module ElixirLS.Utils.OutputDevice is not available)
    ElixirLS.Utils.OutputDevice.get_opts()
    lib/wire_protocol.ex:33: ElixirLS.Utils.WireProtocol.intercept_output/2
    lib/language_server/cli.ex:6: ElixirLS.LanguageServer.CLI.main/0
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir) lib/code.ex:232: Code.eval_string/3
[Info  - 1:10:00 PM] Connection to server got closed. Server will restart.
** (UndefinedFunctionError) function ElixirLS.Utils.OutputDevice.get_opts/0 is undefined (module ElixirLS.Utils.OutputDevice is not available)
    ElixirLS.Utils.OutputDevice.get_opts()
    lib/wire_protocol.ex:33: ElixirLS.Utils.WireProtocol.intercept_output/2
    lib/language_server/cli.ex:6: ElixirLS.LanguageServer.CLI.main/0
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir) lib/code.ex:232: Code.eval_string/3
[Info  - 1:10:02 PM] Connection to server got closed. Server will restart.
** (UndefinedFunctionError) function ElixirLS.Utils.OutputDevice.get_opts/0 is undefined (module ElixirLS.Utils.OutputDevice is not available)
    ElixirLS.Utils.OutputDevice.get_opts()
    lib/wire_protocol.ex:33: ElixirLS.Utils.WireProtocol.intercept_output/2
    lib/language_server/cli.ex:6: ElixirLS.LanguageServer.CLI.main/0
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir) lib/code.ex:232: Code.eval_string/3
[Error - 1:10:02 PM] Connection to server got closed. Server will not be restarted.

我可以进行扩展以使用 elixir 的全球版本(由 ASDF 设置)吗?

4

1 回答 1

1

在运行任何需要 Elixir 的东西(例如,在您的情况下为 VScode 和 ElixirLS)之前,您可以通过设置临时 shell 版本来覆盖 elixir 版本 - asdf shell elixir <elixir version you want>。这将设置 asdf shim 在运行时读取的 shell 环境变量,该变量将覆盖在.tool-versions. 当然,您需要在系统上安装您想要使用的 Elixir 版本,并从设置了环境变量的 shell 启动所有内容。

或者,您可以尝试这样的事情来.tool-versions完全禁用文件读取 - https://github.com/asdf-vm/asdf/issues/870#issuecomment-780862765

于 2021-12-20T16:08:10.087 回答