azdavis / millet

A language server for Standard ML.
https://azdavis.net/posts/millet
Apache License 2.0
210 stars 12 forks source link

Don't depend on rustfmt to build Millet #7

Closed marsam closed 2 years ago

marsam commented 2 years ago

Hi:

Thank you for your work in Millet, I'm using it with Emacs and it works great.

I packaged Millet in nixpkgs but while packaging it, I got an error when I tried to build it without having rustfmt installed. The error was a bit cryptic, but I could solved it adding rustfmt to the dependencies. It happens because syntax-gen depends on it https://github.com/azdavis/language-util/blob/8ec2dc509c88951102ad3e751820443059a363af/crates/syntax-gen/src/util.rs#L37

I think it could be great if the readme had a mention of the dependency of rustfmt or making it optional.

Environment

Steps to reproduce

  1. Try to build millet without having rustfmt installed
  2. Fails

Expected behavior

Build Millet sucessfully

Actual behavior

   $ cargo build --frozen --release --package lang-srv
   ...
   Compiling num_threads v0.1.6
   Compiling atty v0.2.14
   Compiling rowan v0.15.5
   Compiling syntax-gen v0.1.0 (https://github.com/azdavis/language-util.git#8bc99938)
   Compiling colored v2.0.0
   Compiling unicode-normalization v0.1.21
   Compiling syntax v0.1.0 (/private/tmp/nix-build-millet-0.2.5.drv-0/source/crates/syntax)
   Compiling idna v0.2.3
error: failed to run custom build command for `syntax v0.1.0 (/private/tmp/nix-build-millet-0.2.5.drv-0/source/crates/syntax)`

Caused by:
  process didn't exit successfully: `/private/tmp/nix-build-millet-0.2.5.drv-0/source/target/release/build/syntax-ca23e9b6d7a200a8/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', crates/syntax/build.rs:37:4
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: builder for '/nix/store/qiqynfpx00i4gx7fgx465zwn8zf01ahk-millet-0.2.5.drv' failed with exit code 101;
       last 10 log lines:
       >    Compiling syntax v0.1.0 (/private/tmp/nix-build-millet-0.2.5.drv-0/source/crates/syntax)
       >    Compiling idna v0.2.3
       > error: failed to run custom build command for `syntax v0.1.0 (/private/tmp/nix-build-millet-0.2.5.drv-0/source/crates/syntax)`
       >
       > Caused by:
       >   process didn't exit successfully: `/private/tmp/nix-build-millet-0.2.5.drv-0/source/target/release/build/syntax-ca23e9b6d7a200a8/build-script-build` (exit status: 101)
       >   --- stderr
       >   thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', crates/syntax/build.rs:37:4
       >   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       > warning: build failed, waiting for other jobs to finish...
       For full logs, run 'nix log /nix/store/qiqynfpx00i4gx7fgx465zwn8zf01ahk-millet-0.2.5.drv'.
azdavis commented 2 years ago

hm ok, let me see if i can only run rustfmt on the generated code if it's available. (also thanks for using millet! :D)

azdavis commented 2 years ago

updated millet to depend on a recent version of language-util, which just writes files without piping through rustfmt if rustfmt couldn't be spawned: https://github.com/azdavis/language-util/commit/966da5f9a9791ac555a18ebcc39459e7f0d47dd8

then tested it locally by

  1. removing rustfmt from my path
  2. verifying the old version panicked in the same way
  3. updating millet to use the new version
  4. verifying it built without error
  5. opening up the built files
  6. verifying they were not formatted with rustfmt
  7. re-adding rustfmt to my path
  8. re-building the built files
  9. verifying this time they were formatted