# Configuration file directories

**URL:** <https://discourse.julialang.org/t/configuration-file-directories/125925>\
**Category:** General Usage\
**Created:** [February 14, 2025, 10:09pm UTC](https://discourse.julialang.org/t/configuration-file-directories/125925 "2025-02-14T22:09:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![phma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phma/32/6576_2.png) [@phma](https://discourse.julialang.org/u/phma)\
**Post date:** [February 14, 2025, 10:09pm UTC](https://discourse.julialang.org/t/configuration-file-directories/125925/1 "2025-02-14T22:09:52Z")

</div>

Is there a function that returns the list of directories to look for configuration files in? For example, my home directory is `/home/phma/`, so it should return `["/etc/","/home/phma/.local/etc/"]` or something like that.

---

<div class="post-metadata">

**Author:** ![Soel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soel/32/214997_2.png) [@Soel](https://discourse.julialang.org/u/Soel)\
**Post date:** [February 16, 2025, 10:29am UTC](https://discourse.julialang.org/t/configuration-file-directories/125925/2 "2025-02-16T10:29:33Z")

</div>

Have you tried `readdir`/`walkdir` ?  
You can use `filter`/`filter!` in conjunction with `endswith`/`contains` if config files identifiable by some string patterns…

---

<div class="post-metadata">

**Author:** ![phma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phma/32/6576_2.png) [@phma](https://discourse.julialang.org/u/phma)\
**Post date:** [February 16, 2025, 11:49am UTC](https://discourse.julialang.org/t/configuration-file-directories/125925/3 "2025-02-16T11:49:44Z")

</div>

I know about `readdir`, but that’s the answer to not the question I asked. The part of the name of the configuration file after `etc/` is known, but which directories to look for configuration files in depends on where the program is installed (or if it’s not installed, i.e. I’m running it from the source directory) and the operating system (in DragonFly, if a program is installed in `/usr/local/bin/`, it should look in `/usr/local/etc/`).

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [February 16, 2025, 5:59pm UTC](https://discourse.julialang.org/t/configuration-file-directories/125925/4 "2025-02-16T17:59:46Z")

</div>

There’s BaseDirs.jl with [Usage · BaseDirs.jl](https://tecosaur.github.io/BaseDirs.jl/stable/usage/#BaseDirs.config) , but it’s not anywhere near as sophisticated as you want it to be - BaseDirs is basically an implementation of the common XDG spec, whereas you want something that knows about the intricacies of different (non-portable) directory conventions and returns the appropriate one for the current system.

---

<div class="post-metadata">

**Author:** ![phma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phma/32/6576_2.png) [@phma](https://discourse.julialang.org/u/phma)\
**Post date:** [February 18, 2025, 5:11am UTC](https://discourse.julialang.org/t/configuration-file-directories/125925/5 "2025-02-18T05:11:49Z")

</div>

`BaseDirs.config()` returns `/etc/xdg` etc., which as far as I can figure out is for desktop applications, which what I’m writing is not. I think I’ll write my own module, using the user’s home directory and others.
