Skip to content

Specifying --build-path inside the sketch directory is not handled correctly #1646

Closed
@kalj

Description

@kalj

Bug Report

Current behavior

If I compile my project twice with the --build-path argument specifying a directory inside the sketch directory, the second time it fails.

I run

arduino-cli compile --fqbn arduino:avr:mega --build-path build-mega

First time:

Sketch uses 8396 bytes (3%) of program storage space. Maximum is 253952 bytes.
Global variables use 1451 bytes (17%) of dynamic memory, leaving 6741 bytes for local variables. Maximum is 8192 bytes.

But second time:

Error during build: unable to read contents of the source item: open <mydir>/build-mega/compile_commands.json: no such file or directory

This confusing message is completely irrelevant since that file was in fact existing since last compilation. However, as part of the recompilation, the whole build directory was wiped but an entry to compile_commands.json (and other files) remained in the program state which lead to the program trying to read it.

Expected behavior

I expect repeated builds to work with the --build-path specifying a directory inside the sketch directory.

Environment

  • CLI version (output of arduino-cli version): arduino-cli Version: 0.20.2 Commit: 1378381 Date: 2021-12-09T13:32:05Z
  • OS and platform: Ubuntu 21.10, Lenovo Thinkpad P14s with AMD Ryzen 7 PRO 5850U

Additional context

The code I am trying to build: https://github.com/kalj/gep


Note: the original title of this issue was "--build-path results in empty/invalid compile_commands.json"

Metadata

Metadata

Labels

criticality: mediumOf moderate impacttopic: 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