Skip to content

VS Code extension doesn't find installed version of CSharpier, fails silently #1348

Open

Description

@tysonstewart

Environments

  • IDE Version: VS Code 1.93.1
  • Extension Version: 1.8.0
  • CSharpier Version: 0.29.0, 0.29.1
  • Operating System: Ubuntu devcontainer on both Mac and Windows
  • .csharpierrc Settings: N/A
  • .editorconfig Settings: N/A
  • .NET version: 7.0
  • Devcontainer image: mcr.microsoft.com/vscode/devcontainers/dotnet:0-7.0

Log Output

["ERROR" - 8:38:23 PM] CSharpier was not found so files may not be formatted.

It then tries to install from NuGet and seems to ignore the NuGet.Config in the project directory, so I got an error here too until I added the NuGet repo to $HOME/.nuget/NuGet/NuGet.Config.

So then when you try to format files, you get something like:

Formatting started for $PATH using NULL

Steps to reproduce

  1. Set up a devcontainer using the image above.
  2. Install the tool with dotnet tool install csharpier (using -g also does not work)
  3. Remove the nuget.org repo from your packageSources in $HOME/.nuget/NuGet/NuGet.Config
  4. Reload VS Code window
  5. Try to format a .cs file

This is reproducible for me and my colleagues across our platforms, but may have something to do with our repo and/or devcontainer configuration.

Expected behavior

The extension should find the locally-installed tool and use it without needing to resort to fetching it from nuget.org. It would also be nice if it gave a little help in the UI when it's in this state. For me, when I removed the nuget.org repo from my $HOME config (but it was still in the repo config) and rebuilt the devcontainer, formatting suddenly stopped working. That was really unexpected and I wasn't sure where to go from there.

Actual behavior

The extension fails to find CSharpier, tries to install from NuGet, and if that fails, silently fails to format.


Workaround: ensure that the nuget.org repo is a package source in $HOME/.nuget/NuGet/NuGet.Config in the container and it should work OK, but will probably ignore the version you have configured in your repo .config/dotnet-tools.json if any.

Just want to add, though: we really like this extension. Microsoft's C# Dev Kit extension just doesn't cut it when it comes to code formatting. Thank you for this!

Activity

  1. added this to the Planned - Extensions milestone on Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions