-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Improve error message if dotnet is not found #1733
Improve error message if dotnet is not found #1733
Conversation
Requires instead:
`where.exe /?`
(Note: I'm using So I suggest to keep directory separate: let tryGetTool dir toolName =
if isWin then
let pattern =
match dir with
| Some dir ->
$"{dir}:{toolName}"
| None -> toolName
spawnAndGetTrimmedOutput "where.exe" (ResizeArray [ pattern ])
|> Promise.map (fun (err, path, errs) -> if path <> "" then Some path else None)
|> Promise.map (
Option.bind (fun paths ->
paths.Split('\n')
|> Array.map (String.trim)
|> Array.tryHead)
)
else
let tool =
match dir with
| Some dir -> path.join (dir, toolName)
| None -> toolName
spawnAndGetTrimmedOutput "which" (ResizeArray [ tool ])
|> Promise.map (fun (err, path, errs) -> if path <> "" then Some path else None) (also: no need to use |
@Booksbaum Thank you for checking. I think I will go with the less fancy way and just use This was actually my original idea. |
I made the changes to use standard Node API to check for the file existence. |
@baronfel This PR is ready to merge depending on the decision about:
|
I worry about the user experience of having tons of error modals fired. Is there a way we could detect not finding dotnet (until the configuration changes) and then try again? Ideally notifying the user via status bar or something that we're in a degraded state? |
From what I understand you should only see the modal error once. At least, I had the modal only once when starting VSCode with an invalid path. Because, if Perhaps, if the user close the modal, and execute one of the command which invoke Workflow:
|
Another ideas, I had this morning is: Display a minimal notifications just saying "Could not find 'dotnet'" and had an action to the notification saying "More details". When the user click on it, we open a preview panel with the detailed error message in it. dotnet_not_found_md_demo.mp4If we go this way, I think it makes sense to "generalise calling let dotnetNotFound (msg: string) =
promise {
let! selection = window.showErrorMessage ("Could not find 'dotnet'", "More details")
match selection with
| Some "More details" ->
// Prepare a temporary file to store the error message
let fileName = "ionide_dotnet_not_found_details_" + node.crypto.randomBytes(4).readUInt32LE(0).ToString() + ".md"
let tempPath = node.path.join (node.os.tmpdir(), fileName)
// Write the error message to the file, this will allow us to close the text editor
// without a confirmation dialog as the file content will not be modified.
node.fs.writeFileSync(tempPath, msg)
// Open the file in VSCode
let newFile = vscode.Uri.parse (tempPath)
let! document = workspace.openTextDocument newFile
let! _ = window.showTextDocument (document, ?options = None)
// Show the error message in the markdown preview (better display)
do! commands.executeCommand("markdown.showPreview", Some (box document))
// Close the text editor (this does not close the markdown preview)
do! commands.executeCommand("workbench.action.closeActiveEditor", Some (box document))
// Delete the temporary file as it is not needed anymore.
node.fs.unlinkSync(U2.Case1 tempPath)
| Some _
| None ->
()
return failwith "no `dotnet` binary found"
} Edit: If you know a better way to display the detailed error message I am open to suggestion. I think there the possibility to register a custom TextDocumentContentProvider via Example: https://github.com/microsoft/vscode-extension-samples/tree/main/virtual-document-sample |
…ectly it is a relic of the past.
6e3d32e
to
035a448
Compare
Hello @baronfel @Krzysztof-Cieslak, I rebased this PR to the latest version of main + improved the error display as show in my last message. For me this PR is ready for review now. |
Thanks a lot! ❤️ |
Hello,
this PR fix #1709.
Changes:
LanguageService.dotnet
toLanguageService.tryFindDotnet
LanguageService.tryFindDotnet
to gives better errors message if dotnet is not foundEnvironement.dotnet
and useLanguageService.tryFindDotnet
insteaddotnet
detection logicFsharp.dotnetRoot
is set or not.Important
Please test on Windows, if the detection works whenFSharp.dotnetRoot
is set to a valid location. In order, to detect if the file exist at that location I am callingEnvironment.tryGetTool
with the full computed path. On Linux, it executeswhich /home/mmangel/.dotnet/dotnet
which return OK if found, but I don't know if the Windows equivalent was with full path too.Test no needed anymore, I am now using the standard Note API to check if the file exist.
Questions
Generalise calling
windows.showErrorMessage
?Should we call
windows.showErrorMessage
everywhere where we handle an error result from callingLanguageService.tryFindDotnet
? If yes, should we just call it directly fromLanguageService.tryFindDotnet
and make it return the dotnet path if found andfailwith ...
if not?What do to with
LanguageService.compilerLocation
?What does
LanguageService.compilerLocation
do?In the old code if
dotnet
is not found, then Ionide try to use thecompilerLocation
which comes from the (LSP?) client. But how can the LSP client be running ifdotnet
is not found ?If my understanding is correct, shouldn't we just remove it? --> Need to remove the commented code
If not, we need to re-add that portion of the logic. Waiting for some explanation to understand how to wire it.
Error preview