Skip to content

Post build hook command fails on Windows with spaces in the path #316

Open
@benlye

Description

@benlye

I have a board package which runs a postobjcopy hook command:
recipe.hooks.objcopy.postobjcopy.01.pattern.windows="{runtime.platform.path}/tools/win/do_version.bat" "{build.path}" "{build.project_name}" "{build.source.path}" {build.board}

If the Windows username includes a space, and the path to the sketch folder includes a space, I get an error when the hook command attempts to run.

For example:

Linking everything together...
[snip linker commands]
"C:\\Users\\Test User\\AppData\\Local\\Arduino15\\packages\\multi4in1\\hardware\\STM32F1\\1.1.1/tools/win/do_version.bat" "C:\\Users\\Test User\\AppData\\Local\\Temp\\arduino_build_753864" Multiprotocol.ino "C:\\Users\\Test User\\GitHub\\DIY-Multiprotocol-TX-Module\\Multiprotocol" MULTI_STM32_WITH_BOOT=110
'C:\Users\Test' is not recognized as an internal or external command,

operable program or batch file.

If I move the sketch to a folder without spaces, or if the build is run from a user account without spaces the hook command runs fine.

To summarize, when running recipe hook commands, spaces are tolerated either in the sketch path or in the platform path, but not both.

I ran arduino-builder with --debug-level=10 and put the output here:
https://gist.github.com/benlye/93733a920caff6ffec6bad5a4605476d

In that example the user profile folder is C:\Users\Test User\ and the sketch path is C:\Temp\foo bar\Multiprotocol.

Maybe the command line escaping is misfiring somewhere?

There is a very old issue logged against the Arduino IDE, but it seems like the problem is really in arduino-builder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    os: windowsSpecific to Windows operating systemtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions