Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tysonstewart opened this issue Sep 17, 2024 · 0 comments

Comments

@tysonstewart
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant