fantomas-for-vs icon indicating copy to clipboard operation
fantomas-for-vs copied to clipboard

Error: "Creating the Fantomas Deamon failed" when saving a file or trying to format in VS

Open abelbraaksma opened this issue 1 year ago • 4 comments

In VS 2022, 17.8.0, with Fantomas 6.2.0 installed both locally (dotnet tool restore) and globally (the command fantomas is available anywhere), I get the following:

Creating the Fantomas Daemon failed:
Fantomas.Client tried to run `dotnet fantomas --daemon` but failed with "Daemon std error: Run "dotnet tool restore" to make the "fantomas" command available.
.
JsonRpc exception:One or more errors occurred."
Attempting to find Fantomas Tool...
Found at: FantomasToolFound
  (FantomasVersion "5.0.6",
   LocalTool
     (Folder
        "D:\Projects\TaskSeq\src\FSharp.Control.TaskSeq.Test"))

Note the odd thing that it says Found at: FantomasToolFould and then FantomasVersion "5.0.6", which is NOT a version I have installed, as far as I know:

PS D:\projects\TaskSeq> dotnet tool list
Package Id      Version      Commands      Manifest
------------------------------------------------------------------------------------------------------------------
fantomas        6.2.0        fantomas      D:\projects\TaskSeq\.config\dotnet-tools.json
PS D:\projects\TaskSeq> dotnet tool list --global
Package Id      Version      Commands
-------------------------------------
fantomas        6.2.2        fantomas

I'm not sure what's happening here. If I had to guess, maybe the tool expects a non-6.x version and should be updated for 6.x?

I can help, just need to figure out how to debug this ;).

abelbraaksma avatar Dec 19 '23 00:12 abelbraaksma

Hmm. Just realized the path it's showing, and that in my case the sln file is in the src dir and not in the root dir. Running dotnet tool restore from the src dir solved the issue.

Not sure why there's a 6.2 installed in the root dir, and globally, and a 5.0.6 installed in this repo. I'll fix that.

This message was really confusing to me, though:

Attempting to find Fantomas Tool...
Found at: FantomasToolFound

This didn't mean that it was found. It meant that there was a manifest file and that in the manifest file, it found a certain version. However, the tool was never installed in this particular directory on this machine for some reason.

If you feel like it, maybe change the above to "Attempting to find Fantomas Tool as specified in the manifest file"? Or something like that?

Sorry for the mess above, I was looking in the wrong direction lol...

abelbraaksma avatar Dec 19 '23 00:12 abelbraaksma

Whoops, my bad.

nojaf avatar Dec 19 '23 07:12 nojaf

I think this might be more something to report in https://github.com/fsprojects/fantomas-for-vs.

Ehm, that's where this currently is, no? 😆

I'll have a look around and see if I can make a few changes that make reasoning about these errors easier and/or fix it such that it finds Fantomas if it's a level up or globally available.

There's also the issue with .fantomasignore, which currently only sometimes works (i.e., if it is in a parent directly, like how .gitignore works, it won't be applied). I might look at that too.

abelbraaksma avatar Dec 19 '23 13:12 abelbraaksma

Abel, I can't repro this. I'll reach out to you on Slack.

deviousasti avatar Jan 16 '24 05:01 deviousasti