fsharp / emacs-fsharp-mode

F# Emacs mode
Apache License 2.0
208 stars 62 forks source link

FsAutoComplete is not installed #236

Closed mzabolotko closed 4 years ago

mzabolotko commented 4 years ago

Description

FsAutoComplete is not installed after M-x eglot The *Messages* buffer content is: https://ci.appveyor.com/api/projects/fsautocomplete/fsautocomplete/artifacts/bin/pkgs/fsautocomplete.netcore.zip?branch=master Contacting host: ci.appveyor.com:443 mm-write-region: Opening output file: Invalid argument, c:/Users/holod/.emacs.d/FsAutoComplete/netcore/fsautocomplete.netcore.zip?branch=master

Repro steps

Please provide the steps required to reproduce the problem

  1. Install fsharp-mode package.

  2. Open any fs file.

  3. Call M-x eglot

Expected behavior

After call M-x eglot, fsharp-mode works well.

Actual behavior

The directory C:\Users\holod\.emacs.d\FsAutoComplete\netcore was created without any content.

Known workarounds

Manually download and unpack https://ci.appveyor.com/api/projects/fsautocomplete/fsautocomplete/artifacts/bin/pkgs/fsautocomplete.netcore.zip?branch=master

Related information

(require 'fsharp-mode)
(require 'eglot-fsharp)

(setq inferior-fsharp-program "dotnet fsi")
(setq-default fsharp-indent-offset 4)

(add-hook 'fsharp-mode-hook 'highlight-indentation-mode)
(add-to-list 'auto-mode-alist '("\.fs[iylx]?$" . fsharp-mode))

(provide 'config-fsharp)
.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.100\

Host (useful for support):
  Version: 3.1.0
  Commit:  65f04fb6db

.NET Core SDKs installed:
  1.1.6 [C:\Program Files\dotnet\sdk]
  1.1.7 [C:\Program Files\dotnet\sdk]
  1.1.9 [C:\Program Files\dotnet\sdk]
  1.1.14 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.3 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.508 [C:\Program Files\dotnet\sdk]
  2.2.108 [C:\Program Files\dotnet\sdk]
  3.1.100 [C:\Program Files\dotnet\sdk]
metatron-the-chronicler commented 4 years ago

@mzabolotko when you extract this thing manually how do you do it so that fsharp-mode finds it correctly?

mzabolotko commented 4 years ago

@mzabolotko when you extract this thing manually how do you do it so that fsharp-mode finds it correctly?

I extracted it to the directory %USERPROFILE%\.emacs.d\FsAutoComplete\netcore (I set the HOME environment variable for Emacs equal %USERPROFILE%). Then I added to my emacs config the following settings:

(require 'fsharp-mode)
(require 'eglot-fsharp)

(setq inferior-fsharp-program "dotnet fsi")
(setq-default fsharp-indent-offset 4)

(add-hook 'fsharp-mode-hook 'highlight-indentation-mode)
(add-to-list 'auto-mode-alist '("\.fs[iylx]?$" . fsharp-mode))

It works.

mzabolotko commented 4 years ago

Hi. I suppose there is a problem with the file-name-nondirectory. This function doesn't remove the url suffix ?branch=master For example, the following code:

(let* ((url (format "https://ci.appveyor.com/api/projects/fsautocomplete/fsautocomplete/artifacts/bin/pkgs/fsautocomplete%szip?branch=master"
              (if (eq eglot-fsharp-server-runtime 'net-core)
              ".netcore."
            ".")))
      (exe (eglot-fsharp--path-to-server))
      (zippath (concat (file-name-directory exe)
          (file-name-nondirectory url))))

produces in my case:

"c:/Users/holod/.emacs.d/FsAutoComplete/netcore/fsautocomplete.netcore.zip?branch=master"

I think it is better to replace with the following code:

(let* ((url (format "https://ci.appveyor.com/api/projects/fsautocomplete/fsautocomplete/artifacts/bin/pkgs/fsautocomplete%szip?branch=master"
              (if (eq eglot-fsharp-server-runtime 'net-core)
              ".netcore."
            ".")))
      (exe (eglot-fsharp--path-to-server))
      (zippath (concat (file-name-directory exe)
         (file-name-nondirectory
            (substring url 0 (string-match-p (regexp-quote "?") url))))))

And I get:

"c:/Users/holod/.emacs.d/FsAutoComplete/netcore/fsautocomplete.netcore.zip"
juergenhoetzel commented 4 years ago

Thanks for investigating this issue:

Indeed "?" is not a valid windows filename character. This should be fixed by #240