Moved from VirtusLab/scala-cli#4201.
Describe the bug
The Nix package of scala-cli provides a wrapper script, but ultimately the scala-cli binary is located in a versioned path in Nix Store, e.g. /nix/store/flpc752pnb8qk0wljdivj8nfdkfxgv76-scala-cli-1.12.2/bin/scala-cli. It creates .bsp files like this:
{
"name": "scala-cli",
"argv": [
"/nix/store/flpc752pnb8qk0wljdivj8nfdkfxgv76-scala-cli-1.12.2/bin/scala-cli",
"bsp",
"--json-options",
"/Users/kubukoz/projects/demos/.scala-build/ide-options-v2.json",
"--json-launcher-options",
"/Users/kubukoz/projects/demos/.scala-build/ide-launcher-options.json",
"--envs-file",
"/Users/kubukoz/projects/demos/.scala-build/ide-envs.json",
"/Users/kubukoz/projects/demos"
],
"version": "1.12.2",
"bspVersion": "2.1.1",
"languages": [
"scala",
"java"
]
}
However, these don't get updated when scala-cli gets upgraded. As a result, once I upgrade scala-cli, existing projects won't work in Metals until I manually remove the BSP config file.
To Reproduce
- Install an older scala-cli via Nix
- Import a build into Metals
- Upgrade scala-cli
java.io.IOException: Cannot run program "/nix/store/flpc752pnb8qk0wljdivj8nfdkfxgv76-scala-cli-1.12.2/bin/scala-cli" (in directory "/Users/kubukoz/projects/demos"): Exec failed, error: 2 (No such file or directory)
Expected behaviour
Metals should regenerate the .bsp/scala-cli.json file (or at least detect the stale path and offer to fix it) when the scala-cli binary path no longer exists.
Suggested solution
As suggested by @tgodzik, Metals could detect that the binary referenced in .bsp/scala-cli.json no longer exists and regenerate the file.
Moved from VirtusLab/scala-cli#4201.
Describe the bug
The Nix package of scala-cli provides a wrapper script, but ultimately the scala-cli binary is located in a versioned path in Nix Store, e.g.
/nix/store/flpc752pnb8qk0wljdivj8nfdkfxgv76-scala-cli-1.12.2/bin/scala-cli. It creates.bspfiles like this:{ "name": "scala-cli", "argv": [ "/nix/store/flpc752pnb8qk0wljdivj8nfdkfxgv76-scala-cli-1.12.2/bin/scala-cli", "bsp", "--json-options", "/Users/kubukoz/projects/demos/.scala-build/ide-options-v2.json", "--json-launcher-options", "/Users/kubukoz/projects/demos/.scala-build/ide-launcher-options.json", "--envs-file", "/Users/kubukoz/projects/demos/.scala-build/ide-envs.json", "/Users/kubukoz/projects/demos" ], "version": "1.12.2", "bspVersion": "2.1.1", "languages": [ "scala", "java" ] }However, these don't get updated when scala-cli gets upgraded. As a result, once I upgrade scala-cli, existing projects won't work in Metals until I manually remove the BSP config file.
To Reproduce
java.io.IOException: Cannot run program "/nix/store/flpc752pnb8qk0wljdivj8nfdkfxgv76-scala-cli-1.12.2/bin/scala-cli" (in directory "/Users/kubukoz/projects/demos"): Exec failed, error: 2 (No such file or directory)Expected behaviour
Metals should regenerate the
.bsp/scala-cli.jsonfile (or at least detect the stale path and offer to fix it) when the scala-cli binary path no longer exists.Suggested solution
As suggested by @tgodzik, Metals could detect that the binary referenced in
.bsp/scala-cli.jsonno longer exists and regenerate the file.