Modify plugins to use dotnet tool list -g to find globally installed version
Environments
- IDE Version: Rider 2024.1.2 Build #RD-241.15989.179
- Extension Version: 1.7.3
- CSharpier Version: 0.28.2
- Operating System: macOS Sonoma 14.5
- .csharpierrc Settings: none
- .editorconfig Settings: none
Log Output
2024-05-23 20:12:35,314 [ 157128] FINE - #c.i.c.CSharpierLogger - Using dotnet found from RiderDotNetActiveRuntimeHost at /usr/local/share/dotnet/dotnet
2024-05-23 20:13:12,162 [ 193976] FINE - #c.i.c.CSharpierLogger - Ensure there is a csharpier process for /Users/myUser/repoRoot/src/projectOne
2024-05-23 20:13:12,176 [ 193990] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/repoRoot/src/projectOne/.config/dotnet-tools.json
2024-05-23 20:13:12,176 [ 193990] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/repoRoot/src/.config/dotnet-tools.json
2024-05-23 20:13:12,176 [ 193990] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/repoRoot/.config/dotnet-tools.json
2024-05-23 20:13:12,177 [ 193991] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/.config/dotnet-tools.json
2024-05-23 20:13:12,177 [ 193991] FINE - #c.i.c.CSharpierLogger - Looking for /Users/.config/dotnet-tools.json
2024-05-23 20:13:12,177 [ 193991] FINE - #c.i.c.CSharpierLogger - Looking for /.config/dotnet-tools.json
2024-05-23 20:13:12,177 [ 193991] FINE - #c.i.c.CSharpierLogger - Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
2024-05-23 20:13:12,178 [ 193992] FINE - #c.i.c.CSharpierLogger - Running /usr/local/share/dotnet/dotnet csharpier --version in /Users/myUser/repoRoot/src/projectOne
2024-05-23 20:13:14,027 [ 195841] FINE - #c.i.c.CSharpierLogger - Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-csharpier does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
2024-05-23 20:13:14,027 [ 195841] FINE - #c.i.c.CSharpierLogger - dotnet csharpier --version output:
2024-05-23 20:13:14,027 [ 195841] FINE - #c.i.c.CSharpierLogger - Using as the version number.
2024-05-23 20:13:14,028 [ 195842] WARN - #c.i.c.CSharpierLogger - CSharpier was not found so files may not be formatted.
The following log appears after clicking "install csharpier globally" in the notification that says csharpier is not installed.
2024-05-23 20:23:26,134 [ 807948] FINE - #c.i.c.CSharpierLogger - Running /usr/local/share/dotnet/dotnet tool install -g csharpier
2024-05-23 20:23:27,177 [ 808991] FINE - #c.i.c.CSharpierLogger - Tool 'csharpier' is already installed.
Steps to reproduce
- Install CSharpier globally on macOS:
dotnet tool install -g csharpier - Open existing C# project in Rider. No .config/dotnet-tools.json present in the project or elsewhere.
- Right click inside a file
Expected behavior Reformat with CSharpier should be clickable.
Actual behavior Reformat with CSharpier is grayed out.
PATH has the dotnet tools:
bash-3.2$ echo $PATH | tr ':' '\n' | grep 'dotnet'
/usr/local/share/dotnet
~/.dotnet/tools
/Users/myUser/.dotnet/tools
CSharpier is two locations on disk:
bash-3.2$ pwd
/Users/myUser/repoRoot/src/projectOne
bash-3.2$ /usr/local/share/dotnet/dotnet csharpier --version
0.28.2
bash-3.2$ ~/.dotnet/tools/dotnet-csharpier --version
0.28.2
bash-3.2$ dotnet csharpier --version
0.28.2
I am wondering if this is some kind of difference between the user the command runs as when executed in rider vs when you run the command yourself on the cli. But that doesn't really make sense if the command to install csharpier fails because it is already installed.
The only thing I can think to try, is uninstall csharpier. And then let rider try to install it.
Otherwise setting it up as a local tool would avoid the issue, because it will find the version from the dotnet-tools.json file.
I can also look into modifying the extensions to make use of dotnet tool list -g to determine the globally installed version instead.
On mac using Rider, I've found that manually installing globally doesn't work. I had to install the plugin and then use the Rider provided option to install locally to the project. It then created the dotnet-tools.json file and worked.
Using the Rider option to install globally also failed.
I can confirm that uninstalling CSharpier globally, then installing it locally through the extension pop-up solves the issue. It also creates a .config folder in the project root. Installing it globally through the pop-up does not work for me either.
I would really appreciate the possibility to use the already installed global tool, instead of a project-specific install.
Installing it globally through the pop-up does not work for me either.
Is there anything in the logs when you try that indicates why it is failing? Ideally I'd get that working as well to avoid any confusion.
Here is the log. I don't see anything that makes it clear why the global install process is failing. If there's any other place where I can look for debug logs outside of Rider logs, please let me know. As a side note, this log is after I reinstalled my OS and Rider, for unrelated reasons.
2024-06-17 10:32:26,236 [3421670] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: #com.intellij.csharpier.CSharpierLogger
2024-06-17 10:32:26,237 [3421671] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: #com.intellij.csharpier.CSharpierLogger
2024-06-17 10:32:26,237 [3421671] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: com.intellij.csharpier.CSharpierLogger
2024-06-17 10:37:30,746 [ 1222] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: com.intellij.csharpier.CSharpierLogger
2024-06-17 10:37:30,746 [ 1222] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: #com.intellij.csharpier.CSharpierLogger
2024-06-17 10:37:30,747 [ 1223] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: com.intellij.csharpier.CSharpierLogger
2024-06-17 10:37:30,747 [ 1223] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: com.intellij.csharpier.CSharpierLogger
2024-06-17 10:37:30,747 [ 1223] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: #com.intellij.csharpier.CSharpierLogger
2024-06-17 10:37:30,747 [ 1223] INFO - #c.i.d.l.LogLevelConfigurationManager - Level DEBUG is set for the following category: com.intellij.csharpier.CSharpierLogger
2024-06-17 10:37:53,283 [ 23759] INFO - #c.i.i.p.m.MarketplaceRequests - Cannot load data from https://plugins.jetbrains.com/api/icon?pluginId=com.intellij.csharpier&theme=DARCULA (statusCode=403)
2024-06-17 10:37:59,917 [ 30393] INFO - #c.i.o.u.i.PluginDownloader - tryDownloadPlugin: com.intellij.csharpier | 1.7.4 | https://plugins.jetbrains.com/pluginManager?id=com.intellij.csharpier&build=RD-241.17011.166&uuid=170624277917677-fc4d-40ba-b0c1-bc94fc6d1a97&updatedFrom
2024-06-17 10:38:10,384 [ 40860] INFO - #c.i.i.p.DynamicPlugins - Plugin com.intellij.csharpier loaded without restart in 92 ms
2024-06-17 10:38:10,495 [ 40971] FINE - #c.i.c.CSharpierLogger - Using dotnet found from RiderDotNetActiveRuntimeHost at /usr/local/share/dotnet/dotnet
2024-06-17 10:38:16,355 [ 46831] FINE - #c.i.c.CSharpierLogger - Ensure there is a csharpier process for /Users/myUser/work/API/src/Api
2024-06-17 10:38:16,375 [ 46851] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/API/src/Api/.config/dotnet-tools.json
2024-06-17 10:38:16,376 [ 46852] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/API/src/.config/dotnet-tools.json
2024-06-17 10:38:16,376 [ 46852] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/API/.config/dotnet-tools.json
2024-06-17 10:38:16,377 [ 46853] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/.config/dotnet-tools.json
2024-06-17 10:38:16,378 [ 46854] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/.config/dotnet-tools.json
2024-06-17 10:38:16,378 [ 46854] FINE - #c.i.c.CSharpierLogger - Looking for /Users/.config/dotnet-tools.json
2024-06-17 10:38:16,378 [ 46854] FINE - #c.i.c.CSharpierLogger - Looking for /.config/dotnet-tools.json
2024-06-17 10:38:16,378 [ 46854] FINE - #c.i.c.CSharpierLogger - Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
2024-06-17 10:38:16,378 [ 46854] FINE - #c.i.c.CSharpierLogger - Running /usr/local/share/dotnet/dotnet csharpier --version in /Users/myUser/work/API/src/Api
2024-06-17 10:38:17,629 [ 48105] FINE - #c.i.c.CSharpierLogger - Could not execute because the specified command or file was not found.
2024-06-17 10:38:17,630 [ 48106] FINE - #c.i.c.CSharpierLogger - dotnet csharpier --version output:
2024-06-17 10:38:17,630 [ 48106] FINE - #c.i.c.CSharpierLogger - Using as the version number.
2024-06-17 10:38:17,632 [ 48108] WARN - #c.i.c.CSharpierLogger - CSharpier was not found so files may not be formatted.
2024-06-17 10:38:17,634 [ 48110] WARN - #c.i.o.a.i.ActionUpdater - 1279 ms to call on BGT ReformatWithCSharpierAction#presentation@EditorPopup (com.intellij.csharpier.ReformatWithCSharpierAction)
2024-06-17 10:38:23,138 [ 53614] FINE - #c.i.c.CSharpierLogger - Running /usr/local/share/dotnet/dotnet tool install -g csharpier
2024-06-17 10:38:27,485 [ 57961] FINE - #c.i.c.CSharpierLogger - disposing of process for version null
2024-06-17 10:38:29,316 [ 59792] FINE - #c.i.c.CSharpierLogger - Ensure there is a csharpier process for /Users/myUser/work/API/src/Api
2024-06-17 10:38:29,320 [ 59796] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/API/src/Api/.config/dotnet-tools.json
2024-06-17 10:38:29,321 [ 59797] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/API/src/.config/dotnet-tools.json
2024-06-17 10:38:29,322 [ 59798] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/API/.config/dotnet-tools.json
2024-06-17 10:38:29,323 [ 59799] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/work/.config/dotnet-tools.json
2024-06-17 10:38:29,323 [ 59799] FINE - #c.i.c.CSharpierLogger - Looking for /Users/myUser/.config/dotnet-tools.json
2024-06-17 10:38:29,324 [ 59800] FINE - #c.i.c.CSharpierLogger - Looking for /Users/.config/dotnet-tools.json
2024-06-17 10:38:29,324 [ 59800] FINE - #c.i.c.CSharpierLogger - Looking for /.config/dotnet-tools.json
2024-06-17 10:38:29,324 [ 59800] FINE - #c.i.c.CSharpierLogger - Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
2024-06-17 10:38:29,324 [ 59800] FINE - #c.i.c.CSharpierLogger - Running /usr/local/share/dotnet/dotnet csharpier --version in /Users/myUser/work/API/src/Api
2024-06-17 10:38:29,654 [ 60130] FINE - #c.i.c.CSharpierLogger - Could not execute because the specified command or file was not found.
2024-06-17 10:38:29,654 [ 60130] FINE - #c.i.c.CSharpierLogger - dotnet csharpier --version output:
2024-06-17 10:38:29,654 [ 60130] FINE - #c.i.c.CSharpierLogger - Using as the version number.
I've updated all of the extensions so that they use dotnet tool list -g to determine the globally installed version of csharpier, this should work more reliably then the old method of running dotnet csharpier --version
Thank you very much!