Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Incorrect relative local library dependency path resolution when sketch file path used as argument #3005

Open
Labels
topic: build-processRelated to the sketch build process topic: codeRelated to content of the project itself type: imperfectionPerceived defect in any part of project
@sparkyb

Description

Describe the problem

In a sketch.yaml profile, you can specify local libraries as dir: <LOCAL_LIB_PATH> (#2930). According to the documentation, "The path could be absolute or relative to the sketch folder." This works correctly if you just run arduino-cli compile from inside the sketch folder or if you pass a path to the sketch folder like arduino-cli compile Sketch. But if you specify the sketch filename on the command line like arduino-cli compile Sketch/Sketch.ino, then it interprets local library paths relative to this sketch file instead of the sketch folder.

To reproduce

  1. Create a project folder.
  2. Within that, create a Libraries/TestLib folder with a TestLib.h and TestLib.cpp in it.
  3. In the project folder, also create a Sketch/Sketch.ino file that has #include <TestLib.h>
  4. Create Sketch/sketch.yaml that has a default profile that includes in its libraries: section dir: ../Libraries/TestLib
  5. From the project folder, run arduino-cli compile Sketch. This will work.
  6. From the project folder, run ardunio-cli compile Sketch/Sketch.ino. This will fail with the error message: Error initializing instance: Invalid library directory in sketch project: ../Libraries/TestLib
  7. If you changed the library path in sketch.yaml to dir: ../../Libraries/TestLib and then run the command in step 6 it will work, but now the command from step 5 won't.

Expected behavior

My expectation is that the filename should be stripped if specified and relative paths should always be relative to the folder whether a file is specified or not. The library path should be dir: ../Libraries/TestLib and work in both steps 5 and 6.

Arduino CLI version

1.3.1

Operating system

Windows

Operating system version

11

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: build-processRelated to the sketch build process topic: codeRelated to content of the project itself type: 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

        AltStyle によって変換されたページ (->オリジナル) /