Skip to content

Support ARDUINO_CONFIG environment variable #2481

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

Closed
3 tasks done
weshouman opened this issue Dec 28, 2023 · 4 comments · Fixed by #2488
Closed
3 tasks done

Support ARDUINO_CONFIG environment variable #2481

weshouman opened this issue Dec 28, 2023 · 4 comments · Fixed by #2488
Assignees
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@weshouman
Copy link

Describe the request

Is it possible to support setting the configuration file using an environment variable?

Currently it's possible to set the config file through multiple ways, like --config-file and by auto checking the current and parent directories. However, using an environment variable to ensure all the upcoming commands will be using the correct config file would ensure consistency and confidence in the result.

Note, as a current workaround, I'm shadowing the arduino-cli command using the following bash function, which indeed works, but it's not a clean solution.

arduino-cli() {
    if [ -n "$ARDUINO_CONFIG" ]; then
        # ARDUINO_CONFIG is set, use it with --config-file
        command arduino-cli --config-file "${ARDUINO_CONFIG}" "$@"
    else
        # ARDUINO_CONFIG is not set, call arduino-cli normally
        command arduino-cli "$@"
    fi
}

Describe the current behavior

No environment variable are mentioned in the documentation that would set the --config-file

Arduino CLI version

Version: 0.34.2

Operating system

Linux

Operating system version

Any

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
@weshouman weshouman added the type: enhancement Proposed improvement label Dec 28, 2023
@per1234 per1234 added the topic: code Related to content of the project itself label Dec 28, 2023
@alessio-perugini
Copy link
Contributor

👋 We currently support something similar via ARDUINO_DIRECTORIES_DATA. When that env var is set the cli will search for arduino-cli.yaml in the path specified by that env. (if you're curious here is the snippet).

@weshouman
Copy link
Author

This actually works.

However, I've just rechecked my use case, and I do have multiple configuration files in the same directory, each with a different name, thus this solution of specifying a directory for the arduino-cli.yaml does not allow arbitrary configuration file naming as allowed by --config-file

@weshouman weshouman reopened this Jan 3, 2024
@alessio-perugini alessio-perugini self-assigned this Jan 4, 2024
@alessio-perugini
Copy link
Contributor

Ok, we can add that.
Implementation notes:

  • add env name: ARDUINO_CONFIG_FILE
  • add doc

@alessio-perugini
Copy link
Contributor

Will be shipped in the v0.36.0 or directly in the v1.0.0-rc.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
3 participants