jmederosalvarado / roslyn.nvim

Roslyn LSP plugin for neovim
MIT License
192 stars 33 forks source link

dotnet restore error #4

Open daver32 opened 8 months ago

daver32 commented 8 months ago

When there's an error in dotnet restore, it fails to log with the error:

Error executing luv callback:
vim/_editor.lua:0: E5560: nvim_err_writeln must not be called in a lua loop callback
stack traceback:
        [C]: in function 'nvim_err_writeln'
        vim/_editor.lua: in function 'notify'
        ...local/share/nvim/lazy/roslyn.nvim/lua/roslyn/install.lua:109: in function 'on_exit'
        /usr/share/nvim/runtime/lua/vim/_system.lua:297: in function </usr/share/nvim/runtime/lua/vim/_system.lua:267>
        [C]: in function 'wait'
        /usr/share/nvim/runtime/lua/vim/_system.lua:95: in function 'wait'
        ...local/share/nvim/lazy/roslyn.nvim/lua/roslyn/install.lua:116: in function 'install'
        ...m/.local/share/nvim/lazy/roslyn.nvim/lua/roslyn/init.lua:152: in function <...m/.local/share/nvim/lazy/roslyn.nvim/lua/roslyn/ini
t.lua:151>

I tried wrapping the log in vim.schedule:

local waited = vim.system({
    dotnet_cmd,
    "restore",
    download_path,
    "/p:PackageName=" .. roslyn_pkg_name,
    "/p:PackageVersion=" .. roslyn_pkg_version,
}, { stdout = false }, function(obj)
    vim.schedule(function()
        if obj.code ~= 0 then
            vim.notify(
                "Failed to restore Roslyn package: " .. vim.inspect(obj),
                vim.log.levels.ERROR,
                { title = "Roslyn" }
            )
        end
    end)
end):wait()

which seems to work, although I'm not sure if it's the correct thing to do.

The actual produced log:

Failed to restore Roslyn package: {
  code = 1,
  signal = 0,
  stderr = ""
}

After dumping the command params, I tried running it manually, and got the output:

Determining projects to restore...
  Failed to download package 'Microsoft.AspNetCore.App.Ref.7.0.12' from 'https://pkgs.dev.azure.com/azure-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/36a629e1-6c5b-4bcd-aa2e-6018802d6b99/nuget/v3/flat2/microsoft.aspnetcore.app.ref/7.0.12/microsoft.aspnetcore.app.ref.7.0.12.nupkg'.
  Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.aspnetcore.app.ref'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 38D3484C-06C2-4EF3-BEBC-6075C0A6194E)).
  Failed to download package 'Microsoft.AspNetCore.App.Ref.7.0.12' from 'https://pkgs.dev.azure.com/azure-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/36a629e1-6c5b-4bcd-aa2e-6018802d6b99/nuget/v3/flat2/microsoft.aspnetcore.app.ref/7.0.12/microsoft.aspnetcore.app.ref.7.0.12.nupkg'.
  Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.aspnetcore.app.ref'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 38D34B28-06C2-4EF3-BEBC-6075C0A6194E)).
  Failed to download package 'Microsoft.AspNetCore.App.Ref.7.0.12' from 'https://pkgs.dev.azure.com/azure-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/36a629e1-6c5b-4bcd-aa2e-6018802d6b99/nuget/v3/flat2/microsoft.aspnetcore.app.ref/7.0.12/microsoft.aspnetcore.app.ref.7.0.12.nupkg'.
  Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.aspnetcore.app.ref'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 38D34A11-06C2-4EF3-BEBC-6075C0A6194E)).
  Failed to download package 'Microsoft.AspNetCore.App.Ref.7.0.12' from 'https://pkgs.dev.azure.com/azure-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/36a629e1-6c5b-4bcd-aa2e-6018802d6b99/nuget/v3/flat2/microsoft.aspnetcore.app.ref/7.0.12/microsoft.aspnetcore.app.ref.7.0.12.nupkg'.
  Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.aspnetcore.app.ref'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 38D34D4F-06C2-4EF3-BEBC-6075C0A6194E)).
  Failed to download package 'Microsoft.AspNetCore.App.Ref.7.0.12' from 'https://pkgs.dev.azure.com/azure-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/36a629e1-6c5b-4bcd-aa2e-6018802d6b99/nuget/v3/flat2/microsoft.aspnetcore.app.ref/7.0.12/microsoft.aspnetcore.app.ref.7.0.12.nupkg'.
  Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.aspnetcore.app.ref'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 38D34C38-06C2-4EF3-BEBC-6075C0A6194E)).
/usr/share/dotnet/sdk/7.0.112/NuGet.targets(132,5): error : Failed to download package 'Microsoft.AspNetCore.App.Ref.7.0.12' from 'https://pkgs.dev.azure.com/azure-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/36a629e1-6c5b-4bcd-aa2e-6018802d6b99/nuget/v3/flat2/microsoft.aspnetcore.app.ref/7.0.12/microsoft.aspnetcore.app.ref.7.0.12.nupkg'. [/tmp/nvim.myusername/w8Fon6/2/ServerDownload.csproj]
/usr/share/dotnet/sdk/7.0.112/NuGet.targets(132,5): error : Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.aspnetcore.app.ref'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 38D34F43-06C2-4EF3-BEBC-6075C0A6194E)). [/tmp/nvim.myusername/w8Fon6/2/ServerDownload.csproj]
/usr/share/dotnet/sdk/7.0.112/NuGet.targets(132,5): error : Central Directory corrupt. [/tmp/nvim.myusername/w8Fon6/2/ServerDownload.csproj]
/usr/share/dotnet/sdk/7.0.112/NuGet.targets(132,5): error :   Invalid argument : '/tmp/nvim.myusername/w8Fon6/2/out/microsoft.aspnetcore.app.ref/7.0.12/hfd4rpoh.wxx' [/tmp/nvim.myusername/w8Fon6/2/ServerDownload.csproj]

I don't really know what that means, or whether it pertains to this plugin at all, although it seems that the roslyn libs actually got restored properly, so the LSP works in the end.

I'm using nvim 0.10 on Linux. dotnet --version is 7.0.112

jmederosalvarado commented 7 months ago

are you still experiencing this issue?

marvindore commented 6 months ago

I encountered this issue as well while running on Linux. In my case it was due to having the wrong dotnet version installed. Upon failing the attempted install failed before it could clean up the tmp folder where it was downloading files, in there was a proj file that said dotnet 7 but I was running dotnet 6. After upgrading to dotnet 7 the script ran past this error.

lawrence-laz commented 6 months ago

Another way is to change the dotnet version in ~/.local/share/nvim/lazy/roslyn.nvim/lua/roslyn/install.lua:

local csproj = {
        -- ...
    [[        <TargetFramework>net7.0</TargetFramework>]],
        -- ...                        ^ set to what you use
jmederosalvarado commented 6 months ago

I'm now packaging the language server in CI and releasing in this repository. I'll change the install process to just download the assets from github releases.