espressif / idf-component-manager

Tool for installing ESP-IDF components
https://components.espressif.com/
Apache License 2.0
42 stars 15 forks source link

Directory does not exist when adding dependency to renamed main component (PACMAN-481) #9

Closed jonathanfoster closed 1 year ago

jonathanfoster commented 1 year ago

The Component Manager version

v1.1.3

ESP-IDF Version

v5.0

python Version

3.10

Operating System

macOS 12.6

Browser (for https://components.espressif.com Issues)

Brave

Description

I'm trying to add a dependency to a main component that has been renamed src and I receive the following error:

$ idf.py add-dependency --component src lvgl/lvgl>=8.*
ERROR: Directory "/Users/$USER/src/project/components/src" does not exist! Please specify a valid component under /Users/$USER/src/project

It appears the components path is added whenever the component is not main. https://github.com/espressif/idf-component-manager/blob/b1813aa551a66989e3969dbb82281a7add2a8b75/idf_component_manager/core.py#L106

To Reproduce

  1. Create a new project
  2. Rename main component to src.
    set(EXTRA_COMPONENT_DIRS "src")
  3. Add dependency
    idf.py add-dependency --component src lvgl/lvgl>=8.*

Expected behaviour

I expect the component to be added to the main src component.

Additional info

No response

I have checked existing issues and online Documentation

kumekay commented 1 year ago

Hi @jonathanfoster, thank you for the issue.

It is expected behavior, the add-dependency command doesn't work with components in the non-default path specified in EXTRA_COMPONENT_DIRS. We will update the help output of the command.

However, it just adds a line to the manifest file, so create src/idf_component.yml file with the content:

dependencies:
  lvgl/lvgl: ">=8.*"

The component will be downloaded on the next run of CMake, for example on idf.py reconfigure

jonathanfoster commented 1 year ago

@kumekay Thanks for the heads up. Updating the help output to specify the constraint is a good start.

I would also consider going a step further and adding an option to support a renamed main component (e.g. --main). The level of effort would be minimal and it wouldn't be a breaking change to the API. And since this behavior is supported by IDF, it would make component manager more cohesive with the rest of the framework.

This may seem like a small issue, and I'm sure it is when you look at IDF as a whole, but these small issues can compound and result in a poor experience for developers. It's these type of small details that really set you apart.

jonathanfoster commented 1 year ago

@kumekay Take a look at PR https://github.com/espressif/idf-component-manager/pull/10 for a way to support renamed main components. Most of the changes are test related, actual code changes are minimal.