# Correctly using directory scope to install packages

**URL:** <https://racket.discourse.group/t/correctly-using-directory-scope-to-install-packages/1921>\
**Category:** Questions & Answers\
**Tags:** package, raco\
**Created:** [May 4, 2023, 7:34pm UTC](https://racket.discourse.group/t/correctly-using-directory-scope-to-install-packages/1921 "2023-05-04T19:34:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Occhioverde](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/occhioverde/32/1147_2.png) [@Occhioverde](https://racket.discourse.group/u/Occhioverde)\
**Post date:** [May 4, 2023, 7:34pm UTC](https://racket.discourse.group/t/correctly-using-directory-scope-to-install-packages/1921/1 "2023-05-04T19:34:53Z")

</div>

Good morning.  
I'm currently experimenting with directory scope in Raco with the objective of managing packets in a more efficient way, but I'm stuck with a strange behavior that I can't seem to understand just by looking at the docs.  
For what I can comprehend from the [`config.rkt` reference](https://download.racket-lang.org/releases/8.8/doc/raco/config-file.html), the following configuration should allow me to use `/usr/racketpkgs` as a directory scope, therefore allowing me to install packages in it while using the dependencies present in the installation scope:

```scheme
#hash(
      (doc-dir . "/usr/share/doc/racket")
      (lib-dir . "/usr/lib/racket")
      (pkgs-dir . "/usr/share/racket/pkgs")
      (share-dir . "/usr/share/racket")
      (include-dir . "/usr/include/racket")
      (bin-dir . "/usr/bin")
      (apps-dir . "/usr/share/applications")
      (man-dir . "/usr/share/man")
      (absolute-installation? . #t)
      (compiled-file-roots . (same "/usr/lib/racket/compiled"))
      (build-stamp . "")
      (doc-search-url . "https://download.racket-lang.org/releases/8.8/doc/local-redirect/index.html")
      (catalogs . ("https://download.racket-lang.org/releases/8.8/catalog/" #f))
      (collects-search-dirs . ("/usr/racketpkgs" #f))
      (links-search-files . ("/usr/racketpkgs/links.rktd" #f))
      (pkgs-search-dirs . ("/usr/racketpkgs" #f))
)

```

The problem, however, is that when I try to run `sudo raco pkg install --scope-dir /usr/racketpkgs/ resource-pool-lib` (with `resource-pool-lib` being a simple package I found that only depends on `base`) Raco prints out

```scheme
Resolving "resource-pool-lib" via https://download.racket-lang.org/releases/8.8/catalog/
Resolving "resource-pool-lib" via https://pkgs.racket-lang.org
Using cached16825330941682533094018 for https://github.com/Bogdanp/racket-resource-pool.git?path=resource-pool-lib
The following uninstalled packages are listed as dependencies of resource-pool-lib:
   base
Would you like to install these dependencies? [Y/n/a/c/?] n
raco pkg install: missing dependencies
  missing packages:
   base

```

suggesting that base is not present on my system.  
Since `base` is obviously present in the installation scope, I can only conclude that I did something wrong in the configuration that makes Raco only look for the dependencies in the target directory itself, but since the meaning of the single parameters is not so clear to me, I'm unable to find out what.  
Thank you in advance to anyone who can help me with this problem.

---

<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:** [May 5, 2023, 11:21am UTC](https://racket.discourse.group/t/correctly-using-directory-scope-to-install-packages/1921/2 "2023-05-05T11:21:32Z")

</div>

What happens if you put the `#f` first in the list?

---

<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:** [May 5, 2023, 11:24am UTC](https://racket.discourse.group/t/correctly-using-directory-scope-to-install-packages/1921/3 "2023-05-05T11:24:33Z")

</div>

Also, shouldn't it be `collects-search-dirs . ("/usr/racketpkgs/collects"` and `pkgs-search-dirs . ("/usr/racketpkgs/pkgs"` ?

---

<div class="post-metadata">

**Author:** ![Occhioverde](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/occhioverde/32/1147_2.png) [@Occhioverde](https://racket.discourse.group/u/Occhioverde)\
**Post date:** [May 8, 2023, 10:48am UTC](https://racket.discourse.group/t/correctly-using-directory-scope-to-install-packages/1921/4 "2023-05-08T10:48:31Z")

</div>

Thank you for your replies, @xgqt!

> [@xgqt](#):
>
> What happens if you put the `#f` first in the list?

Nothing; moving the `#f` at the first place in the list and re-executing the install command yields the exact same result.

> [@xgqt](#):
>
> Also, shouldn't it be `collects-search-dirs . ("/usr/racketpkgs/collects"` and `pkgs-search-dirs . ("/usr/racketpkgs/pkgs"` ?

I tried this change too, but it doesn't produce any effect.

---

<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:** [May 21, 2023, 7:39am UTC](https://racket.discourse.group/t/correctly-using-directory-scope-to-install-packages/1921/5 "2023-05-21T07:39:14Z")

</div>

"Directory" package scope has turned out to be a very low-level construct. What you want to do is create a [Layered Installation](https://docs.racket-lang.org/raco/layered-install.html), likely a [Tethered Installation](https://docs.racket-lang.org/raco/tethered-install.html). Even this is a bit low-level: these features provide the right building blocks for tools, but few uses of them exist yet. If you want something that works out of the box, try [Cross-Compilation and Multi-Version Manager: raco cross](https://docs.racket-lang.org/raco-cross/index.html).

That said, you certainly can use layered and tethered installations to do what you want. Instead of `raco pkg install --scope-dir`, you will likely use `racket --config /path/to/config/dir -l raco -- pkg install resource-pool-lib`. If you set up a tethered layer, you can instead start by running `racket --config /path/to/config/dir -l raco -- setup`, and your layer will get its own `racket` and `raco` executables that operate on that layer by default. (Creation of such "tethered" executables etc. is what distinguishes a tethered layer from a non-tethered layer.)

I have some repositories with relatively simple examples of layered installations:

- [GitHub - LiberalArtist/racket-config-tethered-experiment: Working out how to use config-tethered-console-bin-dir in config.rktd](https://github.com/LiberalArtist/racket-config-tethered-experiment)
- [GitHub - LiberalArtist/racket-issue-3969: Reproduce racket/racket#3969 without Guix](https://github.com/LiberalArtist/racket-issue-3969)
- [GitHub - LiberalArtist/racket-issue-4133: Attempt to reproduce https://github.com/racket/racket/issues/4133](https://github.com/LiberalArtist/racket-issue-4133)

The most extensive use of layers I know of is my packaging of Racket for Guix. Here is the code we currently use to configure layers for our [`racket-minimal`](https://packages.guix.gnu.org/packages/racket-minimal/) and then [`racket`](https://packages.guix.gnu.org/packages/racket) packages on top of bare-bones internal packages like `racket-vm-cs`: [racket.scm\packages\gnu - guix.git - GNU Guix and GNU Guix System](https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/racket.scm#n1021) (While the overall license of Guix is `GPL-3.0-or-later`, I additionally license this code, which I wrote, under `Apache-2.0` or `MIT`, at your option.) Alternatively, here is a more elaborate version I use in my ongoing (albeit slowly) experimental work to expose individual Racket packages as Guix packages, each built in its own layer: [wip-gnu/packages/aux-files/racket/guix-racket-build-lib/build/configure-layer.rkt · main · Philip McGrath / guix-racket-experiment · GitLab](https://gitlab.com/philip1/guix-racket-experiment/-/blob/main/wip-gnu/packages/aux-files/racket/guix-racket-build-lib/build/configure-layer.rkt)
