Skip to content

Missing quotes around {build.path} in platform.txt #957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
astro-stan opened this issue Feb 29, 2020 · 5 comments · Fixed by #965
Closed

Missing quotes around {build.path} in platform.txt #957

astro-stan opened this issue Feb 29, 2020 · 5 comments · Fixed by #965
Assignees
Milestone

Comments

@astro-stan
Copy link

astro-stan commented Feb 29, 2020

Describe the bug
The missing quotes around {build.path} in the prebuild hooks cause the build to fail for paths containing spaces.

To Reproduce
VScode version: 1.42.1
VSCode arduino extension version: 0.2.29
Arduino IDE version: 1.85

Steps to reproduce the behavior:

  1. Create an "output" key in the arduino.json
{
    "sketch": "...",
    "board": "...",
    "configuration": ...,
    "output": "/home/myname/my dir with spaces/myproject/build"
}
  1. Press F1, type "Arduino verify", press enter
  2. Observe the error
    You should see something like
....
bash: line 0: [: too many arguments
mkdir: cannot create directory ‘my’: Permission denied
mkdir: cannot create directory ‘dir’: Permission denied
mkdir: cannot create directory ‘with’: Permission denied
mkdir: cannot create directory ‘spaces’: Permission denied
....

Expected behavior
Successful build

Desktop (please complete the following information):

  • OS: Linux
  • Arduino IDE version: 1.8.5
  • STM32 core version: 1.8.0

Board (please complete the following information):
Any STM32 board

Additional context
Possible fix:
In the platform.txt it the following lines can be observed:

# Create sketch dir if not exists
recipe.hooks.prebuild.1.pattern.windows=cmd /c if not exist "{build.path}\sketch" mkdir "{build.path}\sketch"
recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.path}/sketch ] || mkdir -p {build.path}/sketch"
recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.path}/sketch ] || mkdir -p {build.path}/sketch"

# Create empty {build.opt} if not exists in the sketch dir
recipe.hooks.prebuild.2.pattern.windows=cmd /c if not exist "{build.opt.sourcepath}" type NUL > "{build.opt.path}"
recipe.hooks.prebuild.2.pattern.linux=bash -c "[ -f {build.opt.sourcepath} ] || touch {build.opt.path}"
recipe.hooks.prebuild.2.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || touch {build.opt.path}"

# Force include of SrcWrapper library
recipe.hooks.prebuild.3.pattern.windows=cmd /c echo #include ^<SrcWrapper.h^> > "{build.src_wrapper.path}"
recipe.hooks.prebuild.3.pattern.linux=bash -c "echo $0 > {build.src_wrapper.path}" "#include <SrcWrapper.h>"
recipe.hooks.prebuild.3.pattern.macosx=bash -c "echo $0 > {build.src_wrapper.path}" "#include <SrcWrapper.h>"

Notice how the commands for Linux and macOS do not have quotes around {build.path}. Changing a prebuild hook to something like this:

recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f \"{build.path}/sketch\" ] || mkdir -p \"{build.path}/sketch\""

Note the quotes around "{build.path}/sketch". Changes the error output to:

...
Verifying...
Build options changed, rebuilding all
]: line 0: [: missing `]'
exit status 2
[Error] Exit with code=1

I am not sure if I am overlooking something with the escaped quotes syntax or it crashes somewhere further down. However, I suspect it should be easy to fix.

Related Issue
Originaly opened as microsoft/vscode-arduino#974

@fpistm
Copy link
Member

fpistm commented Mar 2, 2020

Hi @SlavDimov

This is a know restriction.

However, I suspect it should be easy to fix.

Unfortunately not as Arduino interprets the command line and change/protect itself some characters.
Example a ' will be changed to ", a \" will be changed to \\\"
I've tested and searched several way to allow space but without success. So the easiest way is you specified a path without space which is generally a best practice under Linux.

If you find an elegant way to solve this does not hesitate to provide a PR...

@fpistm fpistm added wontfix This will not be worked on and removed wontfix This will not be worked on labels Mar 2, 2020
@fpistm
Copy link
Member

fpistm commented Mar 2, 2020

Currently working on several scripts and maybe I found a way to ease all those stuff...
Let's see how it goes.

@fpistm fpistm self-assigned this Mar 3, 2020
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Mar 3, 2020
Create prebuild.sh script to perform all required actions.
Same script for all supported host OS.
Fixes stm32duino#957 when path contains space.

Signed-off-by: Frederic Pillon <[email protected]>

fix space under windows
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Mar 3, 2020
Create prebuild.sh script to perform all required actions.
Same script for all supported host OS.
Fixes stm32duino#957 when path contains space.

Signed-off-by: Frederic Pillon <[email protected]>
@fpistm
Copy link
Member

fpistm commented Mar 3, 2020

Hi @SlavDimov
I've made a PR to fix this. See #965

@fpistm fpistm added this to the 1.9.0 milestone Mar 3, 2020
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Mar 3, 2020
Create prebuild.sh script to perform all required actions.
Same script for all supported host OS.
Fixes stm32duino#957 when path contains space.

Signed-off-by: Frederic Pillon <[email protected]>
fpistm added a commit that referenced this issue Mar 4, 2020
Create prebuild.sh script to perform all required actions.
Same script for all supported host OS.
Fixes #957 when path contains space.

Signed-off-by: Frederic Pillon <[email protected]>
@astro-stan
Copy link
Author

Hey @fpistm,
thank you for the fix!

@fpistm
Copy link
Member

fpistm commented Mar 4, 2020

welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants