scala-js / vite-plugin-scalajs

Vite plugin for integration of Scala.js
Apache License 2.0
51 stars 10 forks source link

running sbt as a subprocess causes confusion #5

Open scalway opened 1 year ago

scalway commented 1 year ago

I've installed sbt 1.6.1 in a system:

sbt --version
1.6.1

when I've tried to start vite dev server on scalajs-sbt-vite-laminar-chartjs-example on branch laminar-end-state

$ npm run dev

> livechart@0.0.0 dev
> vite

[info] welcome to sbt 1.8.2 (Ubuntu Java 11.0.18)
[info] loading settings for project global-plugins from common.sbt ...
[info] loading global plugins from /home/slovic/.sbt/1.0/plugins
[info] loading settings for project scalajs-sbt-vite-laminar-chartjs-example-build-build-build from metals.sbt ...

so it starts latest sbt version (as file build.properties defined) but sbt-runner version was still 1.6.1 so command failed as seen below:

...
[info] loading settings for project livechart from build.sbt ...
[info] set current project to livechart (in build file:./scalajs-sbt-vite-laminar-chartjs-example/)
[error] Expected symbol
[error] Not a valid command: --
[error] Expected 'debug'
[error] Expected 'info'
[error] Expected 'warn'
[error] Expected 'error'
[error] Expected 'addPluginSbtFile'
[error] --batch
[error]   ^
error when starting dev server:
Error: sbt invocation for Scala.js compilation failed with exit code 1.
    at ChildProcess.<anonymous> (file:./scalajs-sbt-vite-laminar-chartjs-example/node_modules/@scala-js/vite-plugin-scalajs/dist/index.js:24:24)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1090:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

I was able to fix it by simply install current sbt version:

$ cs install sbt

I really don't know what to do with that, it is not critical (simple OS config fix) but could be blocker for many if cannot find help :(.

sjrd commented 1 year ago

Hum, so that's because you had previously installed an older version somewhere on your system, which took precedence?

We probably cannot really do anything about it. Perhaps the existence of this issue with the searchable error message will help future users to troubleshoot, if they end up in the same situation?

gzm0 commented 1 year ago

What we could do is probe sbt --version and fail if it is too old (hopefully there is a "setup" hook for the plugin or something).