Skip to content

all cargo commands error, because some manifest is broken #3851

Closed
@Skgland

Description

@Skgland

Verification

Problem

Independent of the directory and command I run cargo errors with the following error message:

rustup show active-toolchain
error: error parsing manifest: TOML parse error at line 1478, column 23
     |
1478 | [[pkg.rust.target.aarcwin.extensions]]
     |                       ^
invalid table header
expected `.`, `]]`
 cargo --help
error: error parsing manifest: TOML parse error at line 1478, column 23
     |
1478 | [[pkg.rust.target.aarcwin.extensions]]
     |                       ^
invalid table header
expected `.`, `]]`

in vscode the rust-analyzer log is a bit more helpfull with:

rust-analyzer failed to load workspace: Failed to load the project at /home/bennet/git/project/Cargo.toml: Failed to query rust toolchain version at /home/bennet/git/project, is your toolchain setup correctly?: cd "/home/bennet/git/project" && "/home/bennet/.cargo/bin/cargo" "--version" failed, exit status: 1
stderr:
error: error parsing manifest: TOML parse error at line 1478, column 23
     |
1478 | [[pkg.rust.target.aarc<!--a bunch of nul bytes-->win.extensions]]
     |                       ^
invalid table header
expected `.`, `]]`
It shows a bunch of null bytes where `<!--a bunch of nul bytes-->` is. ![image](https://github.com/rust-lang/cargo/assets/3877590/d51f520f-9e40-49f5-b6a9-7c07c6032ff3)

This is under WSL2 Ubuntu on Windows 11, I believe the corruption might be due to a recent export import of the WSL Image/distribution.
But I think cargo should handle this better, at least a filename of the manifest that failed to parse would be good.

Steps

  1. somehow corrupt the manifest file
  2. run any of the command show above

Possible Solution(s)

Include manifest path in error message

Notes

No response

Rustup version

$> rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.78.0 (9b00956e5 2024-04-29)`

Installed toolchains

$> rustup show  
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/bennet/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
esp

active toolchain
----------------

(error: error parsing manifest, TOML parse error at line 1478, column 23
     |
1478 | [[pkg.rust.target.aarcwin.extensions]]
     |                       ^
invalid table header
expected `.`, `]]`
)

OS version

WSL2 under Windows 11 with

$> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions