Arduino-cli: "compile --build-path" does not work for relative paths

Created on 23 Mar 2020  路  11Comments  路  Source: arduino/arduino-cli

I cannot specify a relative path for compile --build-path.

In other words, this does not work:

arduino-cli compile -b adafruit:avr:protrinket3 . -v --build-path ./_build
[... snip ...]
Linking everything together...
Error during build: Rel: can't make /home/ktdreyer/dev/arduino/_build/core/core.a relative to _build

It took me a while to understand this error message.

It does work when I specify an absolute path:

arduino-cli compile -b adafruit:avr:protrinket3 . -v --build-path $PWD/_build

It would be great to make the following improvements:
1) (Easy) Update the help text in compile --help to indicate that --build-path must be an absolute path.
2) (Harder) Support relative paths for --build-path.

CLI bug

All 11 comments

Hey,
Did you mean   arduino-cli compile -b adafruit:avr:protrinket3 . -v --build-path ./_build does not work?

hi @ktdreyer
I just tested and it correctly created a _build folder, compiled the local sketch into it and returned success.
What's your configuration?

My bad, I screwed up my initial report here. I meant to say that the command does not work when I omit "$PWD".

I tried "./_build" and "_build", and neither work.

I tested this on my normal Fedora 31 laptop as well as a completely new fedora:31 container. It always fails at this step:

Error during build: Rel: can't make /tmp/MyFirstSketch/_build/core/core.a relative to ./_build

ok, better now
it fail for me too, obviously :)

Honestly I'm used to extracting absolute paths in my shell scripts as well as in other languages, so don't really feel strong about this, but I can see it might be useful.

what do @rsora and @masci think about it?

Hi,

I have a concern about the issue itself & proposed fix. According to other functions in the CLI library the path have to be absolute, e.g.:
1) Upload and its documentation it should have similar issue
2) Debug
and here
with similar description

and even in Compile for Cache Path.

Why do you want to change compile --build-path functionality, excluding the others?
Therefore, I am suggesting to change documentation rather than fixing compile --build-path, which will cause ambiguity.

Makes sense, we could actually make a small modification to the way paths are handled by allowing support for both absolute and relative paths.
It seems more convenient to have the option to use either.
What do you guys think?

I think users will expect both absolute and relative paths to work. Like when I pass an absolute or relative path to ls, it does what I expect.

Yup, wasted 2 hours figuring out why compile works:

$ arduino-cli compile --fqbn arduino:avr:nano:cpu=atmega328old PrintStringTest.ino
Sketch uses 6136 bytes (19%) of program storage space. Maximum is 30720 bytes.
Global variables use 717 bytes (35%) of dynamic memory, leaving 1331 bytes for local variables. Maximum is 2048 bytes.

but upload doesn't:

$ arduino-cli upload --fqbn arduino:avr:nano:cpu=atmega328old --port /dev/ttyUSB0 PrintStringTest.ino
avrdude: can't open input file build/arduino.avr.nano/..ino.hex: No such file or directory
avrdude: read from file 'build/arduino.avr.nano/..ino.hex' failed
Error during Upload: uploading error: uploading error: exit status 1

@bxparks
we introduced a regression related to passing in input file, but you can compile and upload at once

@ubidefeo: Just wanted to say thanks, the compile --upload flag worked well to work around the relative path problem with the upload command.

@bxparks
good to hear
by the way in the nightly build you should find the --input-file working again.
Of course you'll need to pass in the --fqbn but it works great

Was this page helpful?
0 / 5 - 0 ratings