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

rtx + fish shell fails to launch the language server #967

Closed
Defman21 opened this issue Aug 19, 2023 · 6 comments · Fixed by #968
Closed

rtx + fish shell fails to launch the language server #967

Defman21 opened this issue Aug 19, 2023 · 6 comments · Fixed by #968

Comments

@Defman21
Copy link
Contributor

Defman21 commented Aug 19, 2023

Environment

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

Elixir 1.15.4 (compiled with Erlang/OTP 26)
  • Elixir Language Server version: 0.16.0
  • Operating system: MacOS Ventura 13.5
  • Editor or IDE name (e.g. Emacs/VSCode): VSCode
  • Editor Plugin/LSP Client name and version: 0.16.0

Current behavior

Running /Users/defman/.vscode/extensions/jakebecker.elixir-ls-0.16.0/elixir-ls-release/launch.sh
Preffered shell fish is not supported, continuing in POSIX shell
Looking for ASDF install
ASDF not found
Looking for rtx executable
rtx executable found in /Users/defman/bin/rtx, activating
/Users/defman/.vscode/extensions/jakebecker.elixir-ls-0.16.0/elixir-ls-release/launch.sh: line 50: set: -g: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
[Error - 16:38:48] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 16:38:48] The ElixirLS - api server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 16:38:48] ElixirLS - api client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 16:38:48] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

I assume it fails because rtx activate $preferred_shell ( => rtx activate fish) outputs fish-style config, which is then eval'd by sh, thus failing.

@Defman21
Copy link
Contributor Author

Current workaround: hardcode preferred_shell=bash at this line: https://github.com/elixir-lsp/elixir-ls/blob/master/scripts/launch.sh#L14

@lukaszsamson
Copy link
Collaborator

Fish is not supported and I think it never was. It shouldn’t be difficult to add support if anyone is willing to contribute.

@Defman21
Copy link
Contributor Author

I assume the "support" in this context is "launch.sh" but in fish script? (e.g. if we detect that the preferred shell is fish, execute launch.fish instead). We can't simply relaunch the current script because it's not going to work in fish.

@lukaszsamson
Copy link
Collaborator

I'm not familiar with fish so it's hard to tell. Executing dedicated launch.fish would probably be a best option. The other is to force fallback to bash/zsh

@lukaszsamson
Copy link
Collaborator

A possible solution would be adding

    elif [ "$preferred_shell" = "fish" ]; then
      >&2 echo "Preferred shell is fish, relaunching"
      exec "$(which fish)" -c "$0 relaunch"

and

elif [ "$preferred_shell" = "fish" ]; then
  # in fish shell, convert ELS_ELIXIR_OPTS into a list and pass to elixir
  if [ -n "$ELS_ELIXIR_OPTS" ]
  then
    # Use fish to split ELS_ELIXIR_OPTS into a list and join them back into a space-separated string
    elixir_opts=$(fish -c "string join ' ' (string split ' ' \"$ELS_ELIXIR_OPTS\")")
  else
    elixir_opts=""
  fi
  exec elixir $elixir_opts --erl "$default_erl_opts $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs"

@Defman21
Copy link
Contributor Author

Defman21 commented Aug 19, 2023

I'll try the second option and if it doesn't work, I'll go with the first one (launch.fish).

lukaszsamson pushed a commit that referenced this issue Aug 21, 2023
* Add support for fish shell

* Simplify ELS_ELIXIR_OPTS

* Refactor ELS_ELIXIR_OPTS and ELS_ERL_OPTS argument builder

* Escape strings in test calls

* Remove unnecessary quotes in set els_dir

* Fix asdf detection

* Replace . with source
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

Successfully merging a pull request may close this issue.

2 participants