# User config files

**URL:** <https://racket.discourse.group/t/user-config-files/1659>\
**Category:** General\
**Created:** [January 24, 2023, 3:45pm UTC](https://racket.discourse.group/t/user-config-files/1659 "2023-01-24T15:45:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [January 24, 2023, 3:45pm UTC](https://racket.discourse.group/t/user-config-files/1659/1 "2023-01-24T15:45:46Z")

</div>

Does anyone have a favorite cross-platform method for storing/retrieving per-user configuration options for their apps?

I can’t find it now, so I may have hallucinated it, but I thought I remembered seeing some functions in Racket for loading options from a standard file in the user's home directory.

I see there is an [INI package](https://docs.racket-lang.org/ini/index.html) that looks like it is actively maintained. There’s always the option to just `read` and `write` datums to a file but something more human-readable would be better.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [January 24, 2023, 3:48pm UTC](https://racket.discourse.group/t/user-config-files/1659/2 "2023-01-24T15:48:50Z")

</div>

One option is to use `get-preference` and `put-preferences`.

[https://docs.racket-lang.org/reference/Filesystem.html#(def.\_((lib.\_racket%2Ffile..rkt).\_get-preference))](https://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28lib._racket%2Ffile..rkt%29._get-preference%29%29)

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [January 24, 2023, 3:50pm UTC](https://racket.discourse.group/t/user-config-files/1659/3 "2023-01-24T15:50:43Z")

</div>

The gui `framework` library has a preferences systems: [27&nbsp;Preferences](https://docs.racket-lang.org/framework/Preferences.html)

There's also `envy`: [Envy: An environment variable manager](https://docs.racket-lang.org/envy/index.html)

---

<div class="post-metadata">

**Author:** ![robby](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robby/32/7_2.png) [@robby](https://racket.discourse.group/u/robby)\
**Post date:** [January 24, 2023, 4:01pm UTC](https://racket.discourse.group/t/user-config-files/1659/4 "2023-01-24T16:01:48Z")

</div>

The framework library's preferences doesn't depend (at the module level) on any gui stuff and it builds on the `racket/file` operations to provide an API that is easier to deal with. It works well for DrRacket.

---

<div class="post-metadata">

**Author:** ![xgqt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/xgqt/32/592_2.png) [@xgqt](https://racket.discourse.group/u/xgqt)\
**Post date:** [January 24, 2023, 6:43pm UTC](https://racket.discourse.group/t/user-config-files/1659/5 "2023-01-24T18:43:38Z")

</div>

In case of paths I tend to loosely follow the FreeDesktop's XDG spec and put config files inside `~/.config/APP-NAME`, I believe on windows `~` either expands to `C:\Users\USER\` or the special `APPDATA` directory.  
The proper way would be to pick up XDG\_CONFIG\_HOME env var on Linux and APPDATA on Windows, then append to that the APP-NAME dir path.

In case of formats I had used either a special #lang, Racket data format (rktd) or JSON for my Racket projects.
