Skip to content

Possibly wrong path for fsautocomplete #341

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

Closed
arialdomartini opened this issue May 9, 2024 · 4 comments · Fixed by #342
Closed

Possibly wrong path for fsautocomplete #341

arialdomartini opened this issue May 9, 2024 · 4 comments · Fixed by #342

Comments

@arialdomartini
Copy link

Description

eglot-fsharp--path-to-server expects fsautocomplete to be in netcore subdir. dotnet tool install does not install it in that subdir.

Repro steps

  • Install fsautocomplete with
dotnet tool install --global fsautocomplete --version 0.72.3

as recommended in https://www.nuget.org/packages/fsautocomplete.

  • Notice how fsautocomplete is being installed in ~/.dotnet/tools, not in ~/.dotnet/tools/netcore.
  • Use fsharp-mode and eglot-fsharp

Actual behavior

I get the error:

Error in post-command-hook (#[0 "\303\301!\205�\0r\301q\210\304\305\300\242\306#\210
?\205�\0\307\310\311 \")\207" [(#0) #<buffer Program.fs> eglot--managed-mode buffer-live-p remove-hook post-command-hook t apply eglot--connect eglot--guess-contact] 4]): (file-missing "Doing vfork" "No such file or directory")

Known workarounds

I think the problem is with the function:

(defun eglot-fsharp--path-to-server ()
    "Return FsAutoComplete path."
    (file-truename (concat eglot-fsharp-server-install-dir "netcore/fsautocomplete" (if (eq system-type 'windows-nt) ".exe" ""))))

which uses the hardcoded value netcore/fsautocomplete.

With the help of @protesilaos I modified it to:

(defun eglot-fsharp--path-to-server ()
    "Return FsAutoComplete path."
    (file-truename (concat eglot-fsharp-server-install-dir "fsautocomplete" (if (eq system-type 'windows-nt) ".exe" ""))))

which fixed the problem.
I work on Arch Linux with SDK 8. I am not sure if this path is also valid for other configurations. It would probably a good idea to have that value parametric.

Related information

  • Operating system
    Linux version 6.8.9-arch1-1

  • Emacs version
    GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2023-10-23

  • .NET Runtime, CoreCLR or Mono Version
    8.0.104

@arialdomartini
Copy link
Author

I just found out that the problem arises only if fsautocomplete has being installed via dotnet tool.

The ambiguity could be because dotnet tool and eglot-fsharp install fsautocomplete in 2 different paths:

Tool Install path
dotnet tool ~/.dotnet/tools
eglot-fsharp ~/.dotnet/tools/netcore

@arialdomartini
Copy link
Author

I think I found the problem.
I had this configuration in place:

(use-package eglot-fsharp
  :ensure t
  :after fsharp-mode
  :config
  (setq eglot-fsharp-server-install-dir "~/.dotnet/tools/"))

because I wanted to make sure that fsautocomplete was not downloaded twice. I learnt that by default eglot-fsharp does not downlod fsautocomplete in ~/.dotnet, but in the startard XDG directory.

My suggestion would be to include the hardcoded netcore path in eglot-fsharp-server-install-dir so in case a user configures it, as above, netcore is not added, with something like:

(defcustom eglot-fsharp-server-install-dir
  (concat (locate-user-emacs-file "FsAutoComplete") "/" "netcore")
  "Install directory for FsAutoComplete."
  :group 'eglot-fsharp
  :risky t
  :type 'directory)

With this,

juergenhoetzel added a commit to juergenhoetzel/emacs-fsharp-mode that referenced this issue May 14, 2024
Setting `eglot-fsharp-server-install-dir' to nil disables the custom
"~/.emacs.d/FsAutoComplete/netcore/" tool path.

Fixes fsharp#341
juergenhoetzel added a commit to juergenhoetzel/emacs-fsharp-mode that referenced this issue May 14, 2024
Setting `eglot-fsharp-server-install-dir' to nil disables the custom
"~/.emacs.d/FsAutoComplete/netcore/" tool path.

Fixes fsharp#341
@juergenhoetzel
Copy link
Collaborator

juergenhoetzel commented May 14, 2024

Fixed in #342

(use-package eglot-fsharp
  :ensure t
  :after fsharp-mode
  :custom (eglot-fsharp-server-install-dir nil))

will use the global user tool path.

@arialdomartini
Copy link
Author

Works like a breeze! Thank you.

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