Congratulations to our 2022 Qt Champions!

[LINUX] Build fails with `/bin/sh: 1: Syntax error: "(" unexpected` when using shadow build outside project directory parent containing bracket "("

  • This is a very edge case but it is also about the more general question of how to customize the shell used to build a Qt project on Linux.


    1. Create a directory containing a bracket "(" or ")" in the name, such as "test (bracket)"
    2. Create a new Qt project inside this directory
    3. Go to Project Build Settings, check Shadow Build

    At this point, build works correctly, because everything happens inside "test (bracket)" so the g++ command can use the relative path ../TestBracket/main.cpp.

    2020-01 Qt build fail on path bracket 1 - original shadow build path.png
    2020-01 Qt build fail on path bracket 2 - build without error as relative path avoids bracket dir.png

    1. Still in Project Build Settings, under Shadow Build, change the Build directory to move one level up, by removing "test (bracket)"
    2. Build project

    Result: Build fails with /bin/sh: 1: Syntax error: "(" unexpected / ")" unexpected`

    This time, the g++ command needs to refer to ../test\ (bracket)/TestBracket/main.cpp

    2020-01 Qt build fail on path bracket 3 - shadow build path moved upward needs go down through backet dir.png
    2020-01 Qt build fail on path bracket 4 - build error as relative path needs to go through bracket dir.png

    Note that Qt projects cannot contain space/bracket in the name at creation time, but may after copying/renaming them. Actually I found this bug precisely after duplicating a project and adding brackets in the name (in which case the error happens even if the Shadow Build path is not moved one level above, as the project name itself would contain a bracket).

    Similar issues

    I only found to be similar, although it was failing due to a Windows path "Program Files (x86)", hence the brackets. This makes me think, by the way, that the order only happens on Linux, maybe OSX.

    Possible solution

    According to, using env bash would allow the g++ command to recognize brackets in side double quotes, unlike sh. I don't see how to customize the shell in Qt on Linux, however.


    When using Shadow Build, do not put round brackets "(" nor ")" in any directory of your path to project; or at least, in any directory under where you'll put your Shadow Build.
    In my case, the path to project was rendering absolute for some reason, so I really needed it clean.

    Interestingly, I was checking if my .pro files were supporting spaces, but those were escaped correctly when using $$ without the need for extra double quotes. The g++ command, however, is very generic and doesn't really care about the content of .pro.

  • Lifetime Qt Champion

    Hi @huulong,

    very nicely summed up!

    I've already created QTCREATORBUG-20834 some time ago, and your case fits perfectly there.

    You may comment and vote on that bug, so we at least get a warning from the IDE.


  • Thanks, I voted up for the warning suggestion.

Log in to reply