Getting F# working in VSCode when "dotnet" is not found on MacOSX?
Asked Answered
H

0

6

I'm completely new to dotnet and vscode so I might be missing something trivial. I just want to get F# running in VSCode on my Mac. I first tried installing dotnet from brew:

brew cask install dotnet-sdk

This seems to be working fine from the command line since I could do both dotnet new and dotnet build:

dotnet new console -lang F# -o myproj

Now I installed Visual Studio Code, also from brew:

brew cask install visual-studio-code

I then installed the Ionide-fsharp plugin, opened the myproj folder from vscode and restarted it. I'm then greeted with:

error

I then searched for FSharp.dotnetRoot in the settings and tried to configure this:

enter image description here

But it didn't help (I also tried setting the folder to /usr/local/share/dotnet and /usr/local/share/dotnet/sdk/3.1.100 but nothing worked).

So I completely uninstalled everything (including wiping my ~/.vscode folder) from brew and re-installed everything from the official Microsoft documentation. In the docs it says that the F# support should be built-in to vscode on macosx, but it still recommended me to install Ionide-fsharp when I opened the folder again, so I obeyed. But I just ran into exactly the same problem again.

So my question is: How can I install vscode with working F# support on MacOSX?

Here's my output from vscode "about":

Version: 1.41.0
Commit: 9579eda04fdb3a9bba2750f15193e5fafe16b959
Date: 2019-12-11T17:58:38.338Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Darwin x64 19.2.0

and this is from dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.100/

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

.NET Core SDKs installed:
  3.1.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
Hoover answered 14/12, 2019 at 14:38 Comment(5)
Did you restart vscode after setting the dotnetRoot property? It doesn't say so on the settings description, bit it requires a restart of VS Code to take effect.Dariadarian
Yes I restarted, but it still didn't work.Hoover
Can you post an issue to the ionide repo with a link here or the contents of this message? I and the other maintainers might be able to get more info there.Dariadarian
I posted an issue here: github.com/ionide/ionide-vscode-fsharp/issues/1271Hoover
It's been a while so apologies if these are wrong, but some things to try: (1) Install using the instructions at dotnet.microsoft.com rather than using brew. (2) Add the dotnet SDK location to your PATH environment variable with sudo nano /etc/paths (3) Create symlink with ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/ (you may need to modify the paths slightly for your case).Uhl

© 2022 - 2024 — McMap. All rights reserved.