Unverified Commit c621c6bf authored by Konrad Malik's avatar Konrad Malik Committed by GitHub
Browse files

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

parent 62e66a16
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
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
Original line number Diff line number Diff line
@@ -50,9 +50,14 @@ buildDotnetModule rec {

  nativeBuildInputs = [ jq ];

  patches = [
    # until upstream updates net6.0 here:
    # https://github.com/dotnet/roslyn/blob/6cc106c0eaa9b0ae070dba3138a23aeab9b50c13/eng/targets/TargetFrameworks.props#L20
  patches = [ ./force-sdk_8_0.patch ];
    ./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.