Comments (31)
from fantomas-for-vs.
That's an interesting error, as I installed the tool globally with the -g
flag. Also, the Fantomas plugin worked in other projects.
The improved error reporting is very useful, thanks!
However, good news is that after doing a dotnet tool restore
on the root of the project that didn't work, it now picks it up correctly. Is it possible that if fantomas is configured for a project that it does not attempt to find the tool on the global path?
I don't know if this would also solve it for @Nekroido
, my project was not one with WSL2-hosted files.
from fantomas-for-vs.
Hey @Nekroido,
Sorry for the delayed reply. I suspect it could be a permissions issue.
Here's the issue I'm seeing:
Fantomas.Client tried to run
dotnet tool list
but exited with code 1. File dotnet-tools.json came from another computer and might be blocked to help protect this computer. For more information, including how to unblock, see https://aka.ms/motw
If there's a dotnet tool version defined in dotnet-tools.json
, Fantomas tries to use that specific version.
from fantomas-for-vs.
It will work if there's no tool manifest defined - with the globally installed formatter.
from fantomas-for-vs.
Hi! Sorry, looks like I never pressed the "Comment" button.
I do have the manifest file, but only with the paket
entry. The error I see in my "Output: F# Formatting" is this:
The operation is not supported:
The FantomasResponseCode value '11' is unexpected.
from fantomas-for-vs.
Hello, Code '11' means that Fantomas daemon (your global or local tool) could not be started.
Can you execute:
open System
open System.IO
let userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
Path.Combine(userProfile, ".dotnet", "tools", "fantomas.exe")
in a F# interactive session (dotnet fsi
) and verify that the path that comes out of there exists.
from fantomas-for-vs.
The path exists in the Windows host. It also exists in my Debian host but without the .exe
extension.
from fantomas-for-vs.
Alright, can you execute the exe
in the command line?
You shouldn't see anything, but if that crashes, that already tells us something.
from fantomas-for-vs.
Both executables exit with Input path is missing...
from fantomas-for-vs.
Ah apologies, you need to add the --daemon
flag.
So C:\fullPath\fantomas.exe --daemon
from fantomas-for-vs.
Both executables wait for the input and crash with the following trace when I press Enter:
Unhandled exception. StreamJsonRpc.BadRpcHeaderException: No Content-Length header detected.
at StreamJsonRpc.HeaderDelimitedMessageHandler.ReadCoreAsync(CancellationToken cancellationToken)
at StreamJsonRpc.MessageHandlerBase.ReadAsync(CancellationToken cancellationToken)
at StreamJsonRpc.JsonRpc.ReadAndHandleRequestsAsync()
at Program.main(String[] argv) in C:\Users\nojaf\Projects\fantomas\src\Fantomas.CoreGlobalTool\Program.fs:line 441
from fantomas-for-vs.
Yeah, that sounds about right.
The error you get when pressing enter makes sense.
So, I can conclude here that the daemon can be started but not programmatically on your end.
There could be a bug in Fantomas.Client.
Could you create a script file with:
#r "nuget: Fantomas.Client"
open System.IO
open Fantomas.Client.Contracts
open Fantomas.Client.LSPFantomasService
let service = new LSPFantomasService() :> FantomasService
// TODO: change file path to existing file on your machine
let file = @"C:\Users\nojaf\Projects\HelloWorld\Math.fs"
let content = File.ReadAllText file
let response =
service.FormatDocumentAsync { SourceCode = content; FilePath = file; Config = None }
|> Async.AwaitTask
|> Async.RunSynchronously
printfn "%A" response
What does that output?
from fantomas-for-vs.
It outputs a formatted document in Windows environment when I provide a valid absolute \\wsl$\Debian\...
path. Same for Debian for a /home/...
path.
I see the error you mentioned initially if I use \\wsl.localhost\...
path.
from fantomas-for-vs.
Yeah, the behaviour we see is starting to make some sense.
Something is going wrong when requests are made with UNIX paths inside the Windows host.
from fantomas-for-vs.
Just chiming in as I'm running into the exact same issue. Nothing happens when I try to execute Format Document
(or a variant, like saving with format-on-save set to 'on'). I'm on Windows 10, VS 2022, all recent updates, F# 6.0 etc. Just installed F# Formatting extension. Same output in the Output window:
The operation is not supported:
The FantomasResponseCode value '11' is unexpected.
Running the commands above work just like @Nekroido mentions.
from fantomas-for-vs.
@nojaf Is there a way to get more detailed output, or to set it up for debugging?
I should probably add that we use the .editorconfig
file approach, as there's nothing that we can set inside the F# > Formatting
options window. I know this is an open bug. I dunno if this may have anything to do with the extension not working.
from fantomas-for-vs.
Hi, I don't think .editorconfig
is relevant here.
To debug you could create a sort of integration unit test where you reference Fantomas.Client and try to mimic what the editor is doing in
If you can step into the Fantomas.Client source, I expect
https://github.com/fsprojects/fantomas/blob/0e036ac3c54301fb8208205c1af0613e7bb06636/src/Fantomas.Client/LSPFantomasService.fs#L74
would be a good place to look what exactually happened.
from fantomas-for-vs.
Btw, this is not WSL2. However, I just found out that the formatting does work correctly on an older .NET Framework project, using VS 2022.
@nojaf, thanks, I'll give it a go.
from fantomas-for-vs.
I've published a new version for VS22 that has much better error logging for this case.
Could you please update and post your logs here. 😊
from fantomas-for-vs.
I'll try, let me update.
from fantomas-for-vs.
@deviousasti, silly question, but I only installed this so far through Marketplace. Do you know what to update? I assume I run the build.ps1
script, but then what, just replace some dll somewhere, I guess?
from fantomas-for-vs.
from fantomas-for-vs.
I just did a local compile of the sln file, found the vsix
, uninstalled old, re-installed with vsix
from the release dir.
from fantomas-for-vs.
Oh, yes, that'd work too! 😄
from fantomas-for-vs.
@deviousasti, this is the new output from the tool:
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 "4.6.0",
LocalTool
(Folder
"D:\Projects\MyProject.Tests\Hosting\Subscriptions"))
from fantomas-for-vs.
Is it possible that if fantomas is configured for a project that it does not attempt to find the tool on the global path?
Yes, this is the current behavior.
from fantomas-for-vs.
Yup, it's much clearer where the issue lies now. I can confirm the "file came from another computer" error. I guess I'm out of luck and I need to consider setting up my dev env in Windows host. Unless it's possible to skip loading dotnet-tools.json
and use the globally installed tool instead.
from fantomas-for-vs.
The flow is the following:
It will check if you have a local tool (using dotnet tool list
),
next, it will check if it has a global tool (using dotnet tool list -g
).
So, if you have a global tool in both places that might work but I suspect you will bump into problems when detecting the .editorconfig
.
from fantomas-for-vs.
On WSL2, if there's no local config, I can confirm that the file formats with the global tool.
from fantomas-for-vs.
I have a fresh machine and installed the extension into Visual Studio, getting the same error @abelbraaksma 👍
Tried many things, those are the steps that need to be done in addition to installing this VS extension:
dotnet tool install fantomas-tool -g
Reopening of Visual Studio is sometimes needed. Also
dotnet restore
The options pane is not shown, but that is already mentioned in well handled in #28
from fantomas-for-vs.
I too am running into this. Is there a way to configure Fantomas to look for a global tool if the local tool fails with this specific error?
from fantomas-for-vs.
Related Issues (20)
- Move to fsprojects/fantomas-for-vs? HOT 5
- Microsoft.VisualStudio.Shell.15.0 not found when loading extension HOT 8
- Missing Options: Fantomas Visual Studio 2022 Community Options Menu HOT 3
- Fantomas' package name changed from `fantomas-tool` to `fantomas` HOT 3
- Fantomas does not work in Visual Studio 2022 HOT 6
- Reformating on selection messes text following selection HOT 5
- Fantomas scrambled up a huge script file HOT 8
- Inconsistent version numbers
- Settings page looks different from screenshot and is missing many options HOT 2
- Broken "read the documentation" link HOT 2
- Enable or disable "Format on save" per repo
- The extension stopped working after upgrading Visual Studio 2022 to the latest version 17.4 HOT 2
- Unable to install the extension to VS 2022 on ARM64 HOT 2
- Extension does not load when a folder is opened in VS instead of a solution HOT 1
- Fantomas < 5.0 breaks nested lists HOT 16
- fsharp_multiline_bracket_style setting is not applied HOT 9
- Error in format files inside Visual Studio after updating fantomas to 6.0.0-alpha-010 HOT 7
- [Live buffers] Extension does not work with the new live buffers HOT 3
- Error: "Creating the Fantomas Deamon failed" when saving a file or trying to format in VS HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fantomas-for-vs.