# When might \`(find-lib-dir)\` return \`#f\`?

**URL:** <https://racket.discourse.group/t/when-might-find-lib-dir-return-f/1377>\
**Category:** Questions & Answers\
**Tags:** question\
**Created:** [October 13, 2022, 11:02am UTC](https://racket.discourse.group/t/when-might-find-lib-dir-return-f/1377 "2022-10-13T11:02:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [October 13, 2022, 11:02am UTC](https://racket.discourse.group/t/when-might-find-lib-dir-return-f/1377/1 "2022-10-13T11:02:29Z")

</div>

Functions like [`find-lib-dir`](https://docs.racket-lang.org/raco/dirs.html#%28def._%28%28lib._setup%2Fdirs..rkt%29._find-lib-dir%29%29) from `setup/dirs` document that:

> The result is `#f` if no such directory is available.

What does "available" mean in this context? From experiments, it seems that the functions don't return `#f` merely because the relevant directory does not exist. Are all such functions like [`find-collects-dir`](https://docs.racket-lang.org/raco/dirs.html#%28def._%28%28lib._setup%2Fdirs..rkt%29._find-collects-dir%29%29) in that "a `#f` result is likely only in a stand-alone executable that is distributed without libraries"?

I have some code for Guix to generate `config.rktd` tables for layers that extend some parent layer. Right now, the code runs in an arbitrary Racket and just manipulates the hash tables, which involves some hard-coded assumptions about how a layer is laid out. It seems like it might be better to run the code in the parent layer and use the `setup/dirs` functions, but I'm not sure if I need to be prepared to handle `#f` results.

---

<div class="post-metadata">

**Author:** ![mflatt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/mflatt/32/6_2.png) [@mflatt](https://racket.discourse.group/u/mflatt)\
**Post date:** [October 14, 2022, 10:42pm UTC](https://racket.discourse.group/t/when-might-find-lib-dir-return-f/1377/2 "2022-10-14T22:42:54Z")

</div>

Yes, with the current implementation, `find-lib-dir` can produce `#f` only if `find-collects-dir` produces `#f`. That is generally true of directories where the default is derived from the collection-directory path.

A stand-alone executable disables the collection path with the same mechanism as providing `-X ""` as command-line arguments to `racket`. It's fairly difficult to load anything after `-X ""` — unless some libraries are predefined, as in a stand-alone executable.

For your context, I don't think you need to plan for the case that `find-lib-dir` returns `#f`.
