gleam-lang / gleam

⭐️ A friendly language for building type-safe, scalable systems!
https://gleam.run
Apache License 2.0
17.42k stars 723 forks source link

Return a friendly error message when a lock cannot be established #2282

Open SkyfallWasTaken opened 1 year ago

SkyfallWasTaken commented 1 year ago

The Gleam compiler and LSP errors out with this message:

 INFO language_server_starting
 ...hello human stuff...

 INFO creating_new_language_server_engine path="/home/skyfall/mailbuzz"
error: Fatal compiler bug!

This is a bug in the Gleam compiler, sorry!

Please report this crash to https://github.com/gleam-lang/gleam/issues/new
with this information and the code that produces the crash.

    compiler-cli/src/build_lock.rs:39
    LockFile creation: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
[Info  - 3:37:18 PM] Connection to server got closed. Server will restart.

...repeated a bunch of times...

I also got this error too:

 INFO language_server_starting
 ...hello human stuff...

 INFO creating_new_language_server_engine path="/home/skyfall/mailbuzz"
error: Fatal compiler bug!

This is a bug in the Gleam compiler, sorry!

Please report this crash to https://github.com/gleam-lang/gleam/issues/new
with this information and the code that produces the crash.

    compiler-cli/src/build_lock.rs:39
    LockFile creation: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
error: Fatal compiler bug!

This is a bug in the Gleam compiler, sorry!

Please report this crash to https://github.com/gleam-lang/gleam/issues/new
with this information and the code that produces the crash.

    /cargo/registry/src/index.crates.io-6f17d22bba15001f/lsp-server-0.5.2/src/stdio.rs:29
    called `Result::unwrap()` on an `Err` value: "SendError(..)"
[Error - 3:42:39 PM] Connection to server is erroring. Shutting down server.

While I do need to find out why the lock file can't be created, this probably shouldn't crash the compiler and should error out with a message about the lockfile. The SendError thing is probably related, so I'm including it in this issue too.

SkyfallWasTaken commented 1 year ago

Also found that this happens with the cli too

skyfall@DESKTOP-4OFG9G9:~/mailbuzz$ gleam run
error: Fatal compiler bug!

This is a bug in the Gleam compiler, sorry!

Please report this crash to https://github.com/gleam-lang/gleam/issues/new
with this information and the code that produces the crash.

        compiler-cli/src/build_lock.rs:39
        LockFile creation: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
SkyfallWasTaken commented 1 year ago

Also, cleaning the build directory solved the problem, so yeah, this is a bug.

lpil commented 1 year ago

Hello! This is not a bug with Gleam, although the error message is unclear. The build build tool needs write permissions for ./build and will be able to compile your code without permission.

CrowdHailer commented 5 months ago

Hey I've come across the the same error, I believe.

$ (cd eyg; GLEAM_LOG=trace gleam test)
DEBUG download_deps: locking_build_directory path="/home/peter/Projects/project_wisdom/eyg/build/packages"
error: Fatal compiler bug!

This is a bug in the Gleam compiler, sorry!

Please report this crash to https://github.com/gleam-lang/gleam/issues/new
and include this error message with your report.

Panic: compiler-cli/src/build_lock.rs:38
    LockFile creation: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
Gleam version: 1.0.0
Operating system: linux

If you can also share your code and say what file you were editing or any
steps to reproduce the crash that would be a great help.

You may also want to try again with the `GLEAM_LOG=trace` environment
variable set.

I think it would be helpful to consider as requiring a fix if the compiler returns this message. "This is a bug in the Gleam compiler, sorry!" Potentially all that needs to happen is to support the compiler exiting with a message which is not a crash

lpil commented 5 months ago

Thank you