Skip to content
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

"compile --build-path" does not work for relative paths #630

Closed
ktdreyer opened this issue Mar 23, 2020 · 12 comments · Fixed by #1423
Closed

"compile --build-path" does not work for relative paths #630

ktdreyer opened this issue Mar 23, 2020 · 12 comments · Fixed by #1423
Labels
topic: CLI Related to the command line interface type: imperfection Perceived defect in any part of project

Comments

@ktdreyer
Copy link

ktdreyer commented Mar 23, 2020

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.
@vinay-lanka
Copy link
Contributor

vinay-lanka commented Mar 23, 2020

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

@ubidefeo
Copy link

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?

@ktdreyer
Copy link
Author

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

@ubidefeo
Copy link

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?

@yzykov
Copy link

yzykov commented Mar 29, 2020

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.

@vinay-lanka
Copy link
Contributor

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?

@ktdreyer
Copy link
Author

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.

@bxparks
Copy link

bxparks commented Aug 22, 2020

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

@ubidefeo
Copy link

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

  • cd into your sketch folder
  • `arduino-cli compile --fqbn arduino:avr:nano:cpu=atmega328old -u -p /YOUR/SERIAL/PORT

@bxparks
Copy link

bxparks commented Sep 3, 2020

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

@ubidefeo
Copy link

@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

@per1234 per1234 reopened this Mar 30, 2021
@josejsarmento
Copy link

This is still happening on Mac OS 11.5.2 and arduino-cli 0.18.3

Bug Report

Current behavior

Compiling a sketch with the --build-path flag is not working for me. Whenever I run the following command:

arduino-cli compile --build-path ../ArduinoOutput -b esp8266:esp8266:generic sketch

I get:

Couldn't deeply cache core build: Rel: can't make ../ArduinoOutput relative to /var/folders/gg/v110hgf95ls12d5vvmv2mc0c0000gn/T/arduino-core-cache
Running normal build of the core...

Expected behavior

I expect the program to save the compiled files at the chosen folder and to re-use them when I compile again afterwards. This would be similar to the 'output' option in the Arduino extension in Visual Studio Code.

Environment

  • CLI version (output of arduino-cli version): arduino-cli alpha Version: 0.18.3 Commit: d710b642 Date: 2021-05-21T17:11:27Z
  • OS and platform: Mac OS 11.5.2

@rsora rsora added type: imperfection Perceived defect in any part of project topic: CLI Related to the command line interface labels Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface type: imperfection Perceived defect in any part of project
Projects
None yet
8 participants