rustic icon indicating copy to clipboard operation
rustic copied to clipboard

Environment variables in the config files not supported

Open kuyagic opened this issue 1 year ago • 4 comments

Environment variables in the config files is not properly expanded on windows I set the following

[backup]
exclude-if-present = [".nobackup", "CACHEDIR.TAG"]
iglob-file = ["C:/ProgramData/rustic/ignore.iglob.list"]

this is working. but both %PROGRAMDATA%/rustic/ignore.iglob.list and %PROGRAMDATA%\\rustic\\ignore.iglob.list not working.

Variables are not expanded. This affects both Windows and *Unix

kuyagic avatar Nov 15 '23 14:11 kuyagic

I marked this as enhancement wish as currently there is no substitution of variables in the config file. See also #996

aawsome avatar Jan 11 '24 12:01 aawsome

This feature is a bit more involved as there are more questions arising:

  • Do we only want variable substitution in filenames or elsewhere in the config?
  • Do we want to allow substition only within strings?
  • Do we want to first parse the TOML, then substitute what is appropriate or first substitute and then parse (which would allow to define TOML structures within env variables)?

aawsome avatar Jan 11 '24 12:01 aawsome

There is this library https://crates.io/crates/expand_str, which is an alternative to https://docs.rs/crate/shellexpand/3.1.0 which is useful for tilde expansion.

simonsan avatar Feb 09 '24 22:02 simonsan

I would suggest to start with expanding env variables where shellexpand is also a good candidate. I would actually keep it really simple and just expand everything before we parse the toml. There is the rustic show-config command which is able to show which config rustic is using, so enough possibility for users to debug any strange behavior.

aawsome avatar Feb 19 '24 21:02 aawsome