Skip to content

bevy build does not work for complex config.toml #626

@selvmaya

Description

@selvmaya

CLI version

main (1219ee2)
also a problem on v0.1.0-alpha.2

Relevant system information

  • Rust version
    rustc 1.92.0-nightly (fa3155a64 2025-09-30)
  • Operating system
    Arch Linux: 6.16.8-arch3-1
Contents of global config.toml
# [target.'cfg(target_arch = "x86_64")']
# rustflags = ["-Ctarget-cpu=native"]

[target.'cfg(and(toolchain = stable, target_arch = "x86_64"))']
linker = "/usr/bin/clang"
rustflags = [
  "-Ctarget-cpu=native",
  # use mold *even on stable*
  "-Clink-arg=--ld-path=/usr/bin/mold",
  "-Clink-arg=-fuse-ld=mold" # see bevy's config_fast_builds.toml
]

[target.'cfg(and(toolchain = nightly, target_arch = "x86_64"))']
linker = "/usr/bin/clang"
rustflags = [
  "-Ctarget-cpu=native",
  # "-Clink-arg=--ld-path=/usr/bin/mold", # use "mold" linker
  # "-Clink-arg=-fuse-ld=mold",
  "-Clink-arg=--ld-path=/usr/bin/wild", # use "wild" linker
  "-Zthreads=0", "-Zshare-generics=y" # use nightly-only stuff

What you did

  • Inititalize new -t=2d bevy project
  • Tried building with the subcommand.
    bevy b [-r]

What went wrong

  • What I expected
    bevy_cli starts and finishes build (similarly to cargo build)

  • What actually happened
    It immediately fails with this message:

error: and(toolchain = nightly, target_arch = "x86_64")
   ^ expected one of `=`, `,`, `)` here

(note: yes the error message seems to crop out some of the code)

Additional information

  • Note
    It could be that my ~/.cargo/config.toml cannot be parsed properly (cfg stuff can be obscure and cargo/rust usually does not error even if that is the case).
    If this is the case, I'd love to know why this only happens for bevy_cli and not cargo, as well as how I could avoid this problem in the future. Maybe the error message could be improved?
  • Workaround
    Assuming I shouldn't just fix it (it may be impossible to correctly parse), a fix is to temporarily make my global (~/.cargo/) config.toml inaccessible from cargo or the cli by renaming it (I renamed it config-2.toml).
    This seems to make bevy b work just like cargo b.
    Simply trying to shadow the global config with the local ./.cargo/config.toml (from config_fast_builds.toml) was not enough.
  • Motivation for fix
    It seems I don't really need to use the cli to build, but since it's a command and there is some useful metadata and helpers inside the tool (e.g. bevy b web), I'd like for it to work.

Terminal screenshot:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CLIRelated to the main CLI and not a more specific subcommandC-BugA bug in the programD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions