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
Add envvar system #16829
Add envvar system #16829
Conversation
Fix whitespaces
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Concept ~0 |
Could you show a concrete important use case that this solve that can't be solved with flags/conf file? |
If this is done, it should probably happen after #15934, which clarifies the settings merging a bit. |
@laanwj How QSettings can mess up with it? |
Exactly because of the precedence orders (and exceptions to it, eg datadir
is treated specially in the ui). Don't know if QSettings specifically can
mess with it, but fact is this creates even more configuration
possibilities and wouldn't be surprised if some interaction broke.
…On Tue, Sep 10, 2019, 18:17 Emil Engler ***@***.***> wrote:
@laanwj <https://github.com/laanwj> How QSettings can mess up with it?
The envvars are 'higher' than QSetttings.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16829?email_source=notifications&email_token=AAA65NUJJ6XYVK5SDLAG763QI7CCRA5CNFSM4IUTSBE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6LVQ7Q#issuecomment-530012286>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAA65NXRAZWIZNG3JBAX6PLQI7CCRANCNFSM4IUTSBEQ>
.
|
What's a practical use-case for this? I'd expect this to be more useful for a tool like |
Agree with this two comments. I'm a Concept NACK unless we get some good use cases that outweigh adding another way to configure Bitcoin Core. |
@ryanofsky
B:
|
@elichai, thanks for teaching me how the unix shell works 😉, but I still think environment variables are useful when you want to configure command line and scriptable utilities like For one thing there are shells other than the unix shell. For example, I wouldn't be surprised if there were as many users invoking bitcoin-cli from the windows command line as from the unix shell, and wanting to be able to simply set the bitcoin datadir through an environment variable in the control panel, so it is picked up and used reliably across the system without needing to write long command lines or wrapper scripts. For another thing, unlike aliases, environment variables work across processes rather than just inside a single shell. So if you have a script calling bitcoin-cli, environment variables set before the script can be used to configure bitcoin-cli without having to edit the the script. And this works not only for scripts invoked directly, but scripts invoked indirectly, such as in a Another example would be very awkward interaction between the command line and config file -datadir settings in systemd, where a datadir set in /etc/bitcoin/bitcoin.conf is silently ignored due to command line precedence (#12255 (review)). Introducing an environment variable and new config precedence as suggested there would remove this footgun (though in this case, we need the environment variable to have less precedence than the config value, not greater, which is why I suggested BITCOIN_HOME, and not BITCOIN_DATADIR there). TL;DR. While I tend to agree with Concept NACKs on this feature, I do actually want to know what motivated @emilengler to work on this PR, and if there are real use-cases that this change or another more limited change might be able to solve. (More limited versions of this PR might be only using environment variables for bitcoin-cli, and not bitcoind and bitcoin-qt. Or only interpretting a single environment variable like BITCOIN_DATADIR or BITCOIN_CONF or BITCOIN_OPTS rather than dozens of different obscure variables.) |
@ryanofsky obviously I know that you know unix shell quite good :) I agree with you, curious to hear the use case (which is why I asked exactly that haha) |
@ryanofsky The usecase was like you sad for bitcoin-cli. |
I like this solution. I do see the value of overriding the default datadir / configuration path through a environment option, especially (but not only) for bitcoin-cli. E.g. On some nodes I have the data directory in another path because it doesn't fit on the main drive, and am using aliases for that right now, but the drawback is that it doesn't propagate to scripts. So ACK on adding |
@laanwj |
See #16868 |
Description
This PR adds a way to set CLI args with an environment variable.
The syntax for the envvars are
BITCOIND_<ARGNAME>=<VALUE>
E.g
BITCOIND_DATADIR=/home/emil/bitcoin/
Console arguments override setted envvars.
The envvars are always uppercase.
Testing
Set some envvars
On Unix:
This will start Bitcoin-Qt using the datadir path with an english overlay.
Notes
This also adds a function to ArgsManager to get all added args in a vector.