rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

The main.rs file is not actually created after calling `rust-playground`

Open zino299792 opened this issue 10 months ago • 0 comments

After executing rust-playground, only an emacs buffer is created for main.rs, not the physical file. This will make lsp server like rust-analyzer unable to start cause it expects "either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present".

The full error is like this:

[stderr]  rust-analyzer failed to load workspace: Failed to load the project at /tmp/rust-playground/at-2025-01-05-153947/Cargo.toml: Failed to read Cargo metadata from Cargo.toml file /tmp/rust-playground/at-2025-01-05-153947/Cargo.toml, Some(Version { major: 1, minor: 76, patch: 0 }): Failed to run `cd "/tmp/rust-playground/at-2025-01-05-153947" && "cargo" "metadata" "--format-version" "1" "--manifest-path" "/tmp/rust-playground/at-2025-01-05-153947/Cargo.toml" "--filter-platform" "aarch64-apple-darwin"`: `cargo metadata` exited with an error: error: failed to parse manifest at `/tmp/rust-playground/at-2025-01-05-153947/Cargo.toml`
[stderr]  
[stderr]  Caused by:
[stderr]    no targets specified in the manifest
[stderr]    either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present

Seems like we should save the buffer to make sure the corresponding file is sinked.

zino299792 avatar Jan 05 '25 07:01 zino299792