Bevy 备注 [bevy]

E0786

error[E0786]: found invalid metadata files for crate `serde`                               
  --> C:\Users\...\.cargo\registry\src\...\bevy_math-0.16.1\src\ray.rs:60:42
   |
60 | #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]      
   |                                          ^^^^^^^^^^^^^^^^
   |
   = note: failed to mmap rmeta metadata: '\\?\D:\...\target\release\deps\libserde-f884fbba2cdca77e.rmeta'
   = note: this error originates in the derive macro `serde::Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)

如果在 Windows 设备上 cargo build --release 时遇到这个错误, 那很可能是 Windows 的路径长度限制所致 1. 管理员身份运行如下 Powershell 命令即可启用长路径支持.

New-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

另见 Registry setting to enable long paths - Microsoft Learn.

1

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters.