Hi everyone!
I created a project using the .NET template
The project builds and the preview works, that is great
However I am missing the editor intellisense , to mitigate this problem, I installed the free C# extension.
After adding it to the editor and to the environment (nix), it complained about libicu
missing. So I added the package pkgs.icu.dev
.
I rebuilt the environment again, and this is the error I am facing right now:
2024-06-12 11:43:53.015 [error] Error: Error running dotnet --info: Error: Command failed: dotnet --info
System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.Cli.Utils.RuntimeEnvironment' threw an exception.
---> System.IO.FileNotFoundException: Could not find file '/etc/os-release'.
File name: '/etc/os-release'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.File.ReadAllLines(String path, Encoding encoding)
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.LoadDistroInfoFromLinux()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.GetDistroVersionId()
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.GetOSVersion()
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment..cctor()
--- End of inner exception stack trace ---
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.get_OperatingSystem()
at Microsoft.DotNet.Cli.CommandLineInfo.PrintInfo()
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
.NET SDK:
Version: 8.0.101
Commit: 6eceda187b
Workload version: 8.0.100-manifests.69afb982
Runtime Environment:
Host:
Version: 8.0.1
Architecture: x64
Commit: bf5e279d92
RID: linux-x64
.NET SDKs installed:
8.0.101 [/nix/store/kwihhgnc34rwx14qrmh281spzlbh8gs9-dotnet-sdk-8.0.101/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.1 [/nix/store/kwihhgnc34rwx14qrmh281spzlbh8gs9-dotnet-sdk-8.0.101/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.1 [/nix/store/kwihhgnc34rwx14qrmh281spzlbh8gs9-dotnet-sdk-8.0.101/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
DOTNET_ROOT [/nix/store/qnsnil6z57xcvadi48hmr4b5680vp3p4-dotnet-sdk-6.0.418]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.Cli.Utils.RuntimeEnvironment' threw an exception.
---> System.IO.FileNotFoundException: Could not find file '/etc/os-release'.
File name: '/etc/os-release'
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.File.ReadAllLines(String path, Encoding encoding)
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.LoadDistroInfoFromLinux()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.GetDistroVersionId()
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.GetOSVersion()
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment..cctor()
--- End of inner exception stack trace ---
at Microsoft.DotNet.Cli.Utils.RuntimeEnvironment.get_OperatingSystem()
at Microsoft.DotNet.Cli.CommandLineInfo.PrintInfo()
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
at /home/user/.codeoss-cloudworkstations/extensions/muhammad-sammy.csharp-2.31.19-universal/dist/extension.js:2:1551094
at Generator.throw (<anonymous>)
at a (/home/user/.codeoss-cloudworkstations/extensions/muhammad-sammy.csharp-2.31.19-universal/dist/extension.js:2:1550213)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
This is how my dev.nix
looks like
{ pkgs, ... }: {
channel = "stable-23.11"; # or "unstable"
packages = [
pkgs.dotnet-sdk_8
pkgs.icu.dev
];
env = {
DOTNET_ROOT = "${pkgs.dotnet-sdk}";
};
idx = {
extensions = [
"muhammad-sammy.csharp"
"ms-dotnettools.vscode-dotnet-runtime"
];
previews = {
enable = true;
previews = {
web = {
command = [
"dotnet"
"watch"
"--urls=http://localhost:$PORT"
];
manager = "web";
};
};
};
};
}
If anyone got any clue on how to fix it, I am eager to try out IDX with C#, I am already using it to learn Rust and I am blown away.
Thank you!