roslyn-ls: fix read-only cache dir (#376364)

This commit is contained in:
Konrad Malik
2025-01-24 12:43:30 +00:00
committed by GitHub
parent 62e66a162a
commit c621c6bf2a
2 changed files with 21 additions and 3 deletions
@@ -0,0 +1,13 @@
diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs
index 5c80f55e9dd..17373f36ebf 100644
--- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs
+++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs
@@ -97,7 +97,7 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation
var assemblyLoader = new CustomExportAssemblyLoader(extensionManager, loggerFactory);
var typeRefResolver = new ExtensionTypeRefResolver(assemblyLoader, loggerFactory);
- var cacheDirectory = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location)!, "cache");
+ var cacheDirectory = Path.Combine(Environment.GetEnvironmentVariable("XDG_CACHE_HOME") ?? Path.Combine(Environment.GetEnvironmentVariable("HOME")!, ".cache"), "roslyn");
using var exportProvider = await ExportProviderBuilder.CreateExportProviderAsync(extensionManager, assemblyLoader, serverConfiguration.DevKitDependencyPath, cacheDirectory, loggerFactory);
+8 -3
View File
@@ -50,9 +50,14 @@ buildDotnetModule rec {
nativeBuildInputs = [ jq ];
# until upstream updates net6.0 here:
# https://github.com/dotnet/roslyn/blob/6cc106c0eaa9b0ae070dba3138a23aeab9b50c13/eng/targets/TargetFrameworks.props#L20
patches = [ ./force-sdk_8_0.patch ];
patches = [
# until upstream updates net6.0 here:
# https://github.com/dotnet/roslyn/blob/6cc106c0eaa9b0ae070dba3138a23aeab9b50c13/eng/targets/TargetFrameworks.props#L20
./force-sdk_8_0.patch
# until made configurable/and or different location
# https://github.com/dotnet/roslyn/issues/76892
./cachedirectory.patch
];
postPatch = ''
# Upstream uses rollForward = latestPatch, which pins to an *exact* .NET SDK version.