OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.76k stars 420 forks source link

Linux getting "CompletionService: Could not find document for file" in LSP mode #2396

Open shashank-sharma opened 2 years ago

shashank-sharma commented 2 years ago

I am using release 1.38.2 - omnisharp-linux-x64-net6.0.tar.gz lsp server command: dotnet [ '/lsp-server/omnisharp/OmniSharp.dll', '-lsp' ]

If I try to pass any input to the LSP server, I get this error: "OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService: Could not find document for file /13764770-cc63-11ec-aaac-b3713373339b/file.cs | 0='/13764770-cc63-11ec-aaac-b3713373339b/file.cs'"

And if I check the path of file.cs file which is created, then it's present at exact same directory. Can anyone help me with what might be wrong with the LSP server ? (Tested using Monaco editor)

This is not specific to net6.0, happens with mono as well (Given codebase is same, it's a different issue), so is there any configuration which I might be missing ?

Trimmed logs:

MESSAGE:  {
  jsonrpc: '2.0',
  method: 'window/logMessage',
  params: {
    type: 3,
    message: "OmniSharp.LanguageServerProtocol.LanguageServerHost: Omnisharp server running using Lsp at location '/app' on host 20. | "
  }
}
MESSAGE:  {
  jsonrpc: '2.0',
  method: 'textDocument/didChange',
  params: {
    textDocument: {
      uri: 'file:///13764770-cc63-11ec-aaac-b3713373339b/file.cs',
      version: 2
    },
    contentChanges: [ [Object] ]
  }
}
MESSAGE:  {
  jsonrpc: '2.0',
  id: 1,
  method: 'textDocument/completion',
  params: {
    textDocument: { uri: 'file:///13764770-cc63-11ec-aaac-b3713373339b/file.cs' },
    position: { line: 0, character: 1 },
    context: { triggerKind: 1 }
  }
}
MESSAGE:  {
  jsonrpc: '2.0',
  id: 2,
  method: 'textDocument/completion',
  params: {
    textDocument: { uri: 'file:///13764770-cc63-11ec-aaac-b3713373339b/file.cs' },
    position: { line: 0, character: 1 },
    context: { triggerKind: 1 }
  }
}
MESSAGE:  {
  jsonrpc: '2.0',
  method: 'window/logMessage',
  params: {
    type: 3,
    message: "OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService: Could not find document for file /13764770-cc63-11ec-aaac-b3713373339b/file.cs | 0='/13764770-cc63-11ec-aaac-b3713373339b/file.cs'"
  }
}
MESSAGE:  {
  jsonrpc: '2.0',
  method: 'window/logMessage',
  params: {
    type: 3,
    message: "OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService: Could not find document for file /13764770-cc63-11ec-aaac-b3713373339b/file.cs | 0='/13764770-cc63-11ec-aaac-b3713373339b/file.cs'"
  }
}
filipw commented 2 years ago

You need to have a project file available, since files are added to the workspace through projects.

shashank-sharma commented 2 years ago

@filipw I have project file as:

total 16
drwxr-xr-x 3 root root 4096 May  5 11:04 .
drwxr-xr-x 1 root root 4096 May  5 11:04 ..
-rw-r--r-- 1 root root  239 May  5 11:04 file.csproj
-rw-r--r-- 1 root root    0 May  5 11:04 file.cs
drwxr-xr-x 2 root root 4096 May  5 11:04 obj

And even get some logs as:

{
  jsonrpc: '2.0',
  method: 'o#/projectadded',
  params: {
    MsBuildProject: {
      ProjectGuid: '00000000-0000-0000-0000-000000000000',
      Path: '/13764770-cc63-11ec-aaac-b3713373339b/file.csproj',
      AssemblyName: 'file',
      TargetPath: '/13764770-cc63-11ec-aaac-b3713373339b/bin/Debug/net6.0/file.dll',
      TargetFramework: '.NETCoreApp,Version=v6.0',
      SourceFiles: [Array],
      TargetFrameworks: [Array],
      OutputPath: 'bin\\Debug/net6.0/',
      IntermediateOutputPath: 'obj/Debug/net6.0/',
      Configuration: 'Debug',
      Platform: 'AnyCPU',
      IsExe: true,
      IsUnityProject: false
    }
  }
}
MESSAGE:  {
  jsonrpc: '2.0',
  method: 'o#/projectchanged',
  params: {
    MsBuildProject: {
      ProjectGuid: '00000000-0000-0000-0000-000000000000',
      Path: '/13764770-cc63-11ec-aaac-b3713373339b/file.csproj',
      AssemblyName: 'file',
      TargetPath: '/13764770-cc63-11ec-aaac-b3713373339b/bin/Debug/net6.0/file.dll',
      TargetFramework: '.NETCoreApp,Version=v6.0',
      SourceFiles: [Array],
      TargetFrameworks: [Array],
      OutputPath: 'bin\\Debug/net6.0/',
      IntermediateOutputPath: 'obj/Debug/net6.0/',
      Configuration: 'Debug',
      Platform: 'AnyCPU',
      IsExe: true,
      IsUnityProject: false
    }
  }
}

I made sure that file.csproj is present and dotnet restore happens. Is there something else which is wrong here ?

Rockenstien commented 2 years ago

Any update on this?

vinayb21 commented 1 year ago

@filipw can you please check the filestructure and confirm if anything is missing out? cc/ @shashank-sharma