Skip to content

.bsp/scala-cli not updating when scala-cli is upgraded #8307

@kubukoz

Description

@kubukoz

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

  1. Install an older scala-cli via Nix
  2. Import a build into Metals
  3. Upgrade scala-cli
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions