Skip to content

Running broken build Syntax error: ")" unexpected #8182

@ralpha

Description

@ralpha

I got the error:

target/debug/myproject: 1: target/debug/myproject: Syntax error: ")" unexpected

When building one of my projects.
This error was very likely caused by me canceling the build process at just the right moment.

This is not even really a bug. But made me to force a clean build, so might be something that could be fixed. If not this might help people in the future.
(If you get this problem run cargo clean and build again.)

Problem
Canceled build process and broke executable in later builds.
This is a copy of my terminal when while I got this error (cleaned up a bit).

user@My-PC:/Path_to_Project/myproject$ cargo build
   Compiling df_st_db v0.1.0 (/Path_to_Project/myproject/df_st_db)
   Compiling myproject v0.1.0 (/Path_to_Project/myproject)
    Finished dev [unoptimized + debuginfo] target(s) in 20.72s

------Made minor code changes here...should still compile...and does later on.-----

user@My-PC:/Path_to_Project/myproject$ cargo run
   Compiling df_st_db v0.1.0 (/Path_to_Project/myproject/df_st_db)
   Compiling myproject v0.1.0 (/Path_to_Project/myproject)
^C  Building [=====================================================> ] 203/204: myproject(bin)                 
--- I canceled the build here (see the ^C, for ctrl+c ) ----

user@My-PC:/Path_to_Project/myproject$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.20s
     Running `target/debug/myproject`
target/debug/myproject: 1: target/debug/myproject: Syntax error: ")" unexpected

user@My-PC:/Path_to_Project/myproject$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/myproject`
target/debug/myproject: 1: target/debug/myproject: Syntax error: ")" unexpected

user@My-PC:/Path_to_Project/myproject$ cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s

user@My-PC:/Path_to_Project/myproject$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/myproject`
target/debug/myproject: 1: target/debug/myproject: Syntax error: ")" unexpected

user@My-PC:/Path_to_Project/myproject$ cargo clean
... Some errors that files could not be deleted, but this is irrelevant to this...

user@My-PC:/Path_to_Project/myproject$ cargo run
   Compiling proc-macro2 v1.0.10
   Compiling unicode-xid v0.2.0
... Compiled and runs perfect ....

Steps
See commands above.

Possible Solution(s)
Run cargo clean and cargo build or cargo run. It is now fixed.
(you can probably delete the executable as well and build it again)

In cargo it might be able to detect this? And just build the executable again? (so it is not broken)

Notes
This is not really a bug and might only happen in very infrequently. But it is here if it is useful.
If not just close this issue and it is all good for me.

Output of cargo version:
cargo 1.43.0 (3532cf7 2020-03-17)
rustc 1.43.0 (4fb7144ed 2020-04-20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions