Had to work with Bicep today and VS Code was stuck on this for some reason:
Actually, prior to this it was also throwing an error about being unable to decompile something from my clipboard. I didn’t capture that error, but that went away once I unticked this setting:
But the other error refused to go away. Expanding the details didn’t show anything useful either.
So I clicked View (in the menubar) and Output:
And in the pane that opened, went to Bicep:
Here’s what the output showed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
2024-02-24T10:31:37.294Z info: Current log level: debug. 2024-02-24T10:31:37.297Z info: Acquiring dotnet runtime... 2024-02-24T10:31:37.297Z info: Found config for 'dotnetAcquisitionExtension.existingDotnetPath': {"extensionId":"ms-azuretools.vscode-bicep","path":"/usr/local/share/dotnet/dotnet"} 2024-02-24T10:31:37.312Z debug: Found dotnet command at '/usr/local/share/dotnet/dotnet'. 2024-02-24T10:31:37.312Z info: Launching Bicep language service... 2024-02-24T10:31:37.313Z debug: Found language server at '/Users/xxx/.vscode/extensions/ms-azuretools.vscode-bicep-0.25.53/bicepLanguageServer/Bicep.LangServer.dll'. You must install or update .NET to run this application. App: /Users/rakhesh/.vscode/extensions/ms-azuretools.vscode-bicep-0.25.53/bicepLanguageServer/Bicep.LangServer.dll Architecture: arm64 Framework: 'Microsoft.NETCore.App', version '8.0.0' (arm64) .NET location: /usr/local/share/dotnet/ The following frameworks were found: 6.0.10 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 6.0.11 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 6.0.12 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 6.0.13 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 6.0.14 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 6.0.16 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 6.0.18 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 7.0.0 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 7.0.1 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 7.0.2 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 7.0.3 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 7.0.5 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] 7.0.7 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Learn about framework resolution: https://aka.ms/dotnet/app-launch-failed To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=8.0.0&arch=arm64&rid=osx.14-arm64 |
It couldn’t find .NET? That doesn’t make sense. I am pretty sure I have dotnet installed. Use dotnet --list-sdks
to see the list of installed SDKs and dotnet --list-runtimes
for the list of runtimes. And dotnet —info
for everything. Here’s the output of the latter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
$ dotnet --info .NET SDK: Version: 8.0.101 Commit: 6eceda187b Workload version: 8.0.100-manifests.2fd734c4 Runtime Environment: OS Name: Mac OS X OS Version: 14.2 OS Platform: Darwin RID: osx-arm64 Base Path: /opt/homebrew/Cellar/dotnet/8.0.1/libexec/sdk/8.0.101/ .NET workloads installed: Workload version: 8.0.100-manifests.2fd734c4 There are no installed workloads to display. Host: Version: 8.0.1 Architecture: arm64 Commit: bf5e279d92 .NET SDKs installed: 8.0.101 [/opt/homebrew/Cellar/dotnet/8.0.1/libexec/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 8.0.1 [/opt/homebrew/Cellar/dotnet/8.0.1/libexec/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.1 [/opt/homebrew/Cellar/dotnet/8.0.1/libexec/shared/Microsoft.NETCore.App] Other architectures found: x64 [/usr/local/share/dotnet/x64] Environment variables: DOTNET_ROOT [/opt/homebrew/Cellar/dotnet/8.0.1/libexec] global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download |
One thing though, they all seem to be installed under /opt/homebrew/Cellar
, while the output from the Bicep extension above was looking at /usr/local/share/dotnet/
. That path is present in the output of dotnet -info
too, but as the x64 architecture. I was on my arm64 Mac though. Could that be the issue?
I remembered overriding some paths in the past and that’s when I was on my Intel iMac, so maybe that’s the reason? That time I had added the following to my VS Code settings file:
1 2 3 4 5 6 7 8 9 10 |
"dotnetAcquisitionExtension.existingDotnetPath": [ { "extensionId": "ms-azuretools.vscode-bicep", "path": "/usr/local/share/dotnet/dotnet" }, { "extensionId": "msazurermtools.azurerm-vscode-tools", "path": "/usr/local/share/dotnet/dotnet" } ], |
So I removed that, restarted VS Code, and now there’s no errors!
I am a bit concerned though, coz the output log now shows this:
1 2 3 4 5 6 7 |
2024-02-24T10:56:04.909Z info: Current log level: debug. 2024-02-24T10:56:04.911Z info: Acquiring dotnet runtime... 2024-02-24T10:56:07.303Z debug: Found dotnet command at '/Users/xxx/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/8.0.2~arm64/dotnet'. 2024-02-24T10:56:07.303Z info: Launching Bicep language service... 2024-02-24T10:56:07.303Z debug: Found language server at '/Users/xxx/.vscode/extensions/ms-azuretools.vscode-bicep-0.25.53/bicepLanguageServer/Bicep.LangServer.dll'. 2024-02-24T10:56:07.820Z info: Bicep language service started. [Info - 10:56:07] Running on processId 64657 |
Is it downloading its own version of the runtime and using that? Sounds like it.
The latest version of dotnet as of this blog post is 8.0.2 released on 15th Feb. Looks like Homebrew doesn’t know of it, as my system is still on 8.0.1. On my laptop /opt/homebrew/bin/dotnet
is a link to the current version in the Cellar ../Cellar/dotnet/8.0.1/bin/dotnet
.
I’d like to keep things consistent, so I added the snippet I removed back… but with the correct path.
1 2 3 4 5 6 7 8 9 10 |
"dotnetAcquisitionExtension.existingDotnetPath": [ { "extensionId": "ms-azuretools.vscode-bicep", "path": "/opt/homebrew/bin/dotnet" }, { "extensionId": "msazurermtools.azurerm-vscode-tools", "path": "/opt/homebrew/bin/dotnet" } ], |
Restarted VS Code, and now it’s happy and uses the correct path.
1 2 3 4 5 6 7 8 |
2024-02-24T11:19:02.103Z info: Current log level: debug. 2024-02-24T11:19:02.105Z info: Acquiring dotnet runtime... 2024-02-24T11:19:02.106Z info: Found config for 'dotnetAcquisitionExtension.existingDotnetPath': {"extensionId":"ms-azuretools.vscode-bicep","path":"/opt/homebrew/bin/dotnet"} 2024-02-24T11:19:02.117Z debug: Found dotnet command at '/opt/homebrew/bin/dotnet'. 2024-02-24T11:19:02.117Z info: Launching Bicep language service... 2024-02-24T11:19:02.117Z debug: Found language server at '/Users/xxx/.vscode/extensions/ms-azuretools.vscode-bicep-0.25.53/bicepLanguageServer/Bicep.LangServer.dll'. 2024-02-24T11:19:03.347Z info: Bicep language service started. [Info - 11:19:03] Running on processId 70847 |
One last thing, more as a note for myself. On macOS, with Homebrew, it is possible to install multiple versions of dotnet via brew install dotnet@8
and brew install dotnet@7
etc.