Skip to content

Confused by the config init --dest-dir functionality #2533

Closed
@pillo79

Description

@pillo79
Contributor

Describe the request

As I understand there are 3 ways to initialize the CLI config:

  • arduino-cli config init will initialize the config in ~/.arduino15/arduino-cli.yaml and use ~/.arduino15 as data store;
  • arduino-cli config init --dest-file cfg.yaml will initialize the config in cfg.yaml and use ~/.arduino15 as data store;
  • arduino-cli config init --dest-dir cfg will create a cfg folder, initialize the config in cfg/arduino-cli.yaml and STILL use ~/.arduino15 as data store.

The first way is the generic default.
The second is a variant that allows you to have a different CLI config but share the package repos.
The third works exactly like the second but creates an (otherwise unused) directory. I was really surprised by this as I thought it would initialize a fully separate CLI environment. That is really useful for CI/testing purposes.

What is the use case of the config init --dest-dir option? Can this be edited to automatically point directories.data and directories.download to the specified folder?

Describe the current behavior

Currently to achieve a separate environment, the config has to be initialized and then the directories have to be manually set via arduino-cli config set commands.

Arduino CLI version

0.35.2

Operating system

Linux

Operating system version

--

Additional context

No response

Issue checklist

  • I searched for previous requests in the issue tracker
    I verified the feature was still missing when using the nightly build
    My request contains all necessary details

Activity

cmaglie

cmaglie commented on Jul 30, 2024

@cmaglie
Member

Hi @pillo79

I think the original idea of config init --dest-file cfg.yaml was to match the global flag --config-file cfg.yaml.
BTW the same did not happen for the config init --dest-dir cfg that has no global flag counter part --config-dir ....

Maybe a better strategy is to add a global --config-dir my/config/dir flag that does two things:

  • sets the configuration file to my/config/dir/arduino-cli.yaml
  • sets the default data dir to my/config/dir, so it will be used to store platforms and downloads (note that the directory will not be written in the generated configuration, but just taken as "default").

WDYT?

pillo79

pillo79 commented on Jul 30, 2024

@pillo79
ContributorAuthor

I don't think that is enough, since the generated file specifies these paths explicitly, and it would still override the default set by --config-dir later.

However, it would be fine if doing a config init --dest-dir cfg --config-dir cfg would result in the paths being "set to a custom default" and then written in cfg/arduino-cli.yaml.

cmaglie

cmaglie commented on Jul 30, 2024

@cmaglie
Member

I don't think that is enough, since the generated file specifies these paths explicitly

This behavior is changed from the CLI 1.0.0, now the config file contains only the required field:

$ arduino-cli config init --dest-dir xxxxx
Config file written to: /home/cmaglie/xxxxx/arduino-cli.yaml
$ ls -lR xxxxx/
xxxxx/:
totale 4
-rw-r--r-- 1 cmaglie cmaglie 39 lug 30 17:07 arduino-cli.yaml
$ cat xxxxx/arduino-cli.yaml 
board_manager:
    additional_urls: []
$ 

at this point it could be used as:

$ arduino-cli core install --config-dir xxxxx
...do everything in xxxxx since the default data.dir is now set to xxxxx via --config-dir...
pillo79

pillo79 commented on Jul 30, 2024

@pillo79
ContributorAuthor

Sorry didn't check the latest CLI behavior. I think this would be great! 😄 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @pillo79@cmaglie

    Issue actions

      Confused by the `config init --dest-dir` functionality · Issue #2533 · arduino/arduino-cli