# Racket installation with Nix (Newbie)

**URL:** https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069
**Category:** Questions & Answers
**Created:** [July 3, 2023, 4:15pm UTC](https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069 "2023-07-03T16:15:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![maddalab](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/maddalab/32/1274_2.png) [@maddalab](https://racket.discourse.group/u/maddalab)
#### Post date: [July 3, 2023, 4:15pm UTC](https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069/1 "2023-07-03T16:15:07Z")

</div>

Hello,

Complete noob here, learning both nix and starting racket at the same time - might not be a good idea.

I installed Racket using nix, below is my derivation to install it

```scheme
let
  pkgs = import <nixpkgs> { };
in
pkgs.mkShell {
  buildInputs = [
    pkgs.racket
  ];
}

```

I ran `racket` - played around with the repl and things looked good. I ran `drracket` which resulted in ffi-lib error

```scheme
ffi-lib: could not load foreign library
  path: libX11.6.dylib

```

Update my nix derivation

```scheme
let
  pkgs = import <nixpkgs> { };
in
pkgs.mkShell {
  buildInputs = [
    pkgs.racket
    pkgs.xorg.libX11
    #pkgs.xorg.libX11.dev
  ];
  LD_LIBRARY_PATH="${pkgs.xorg.libX11}/lib";
}

```

This both installs libX11 and set up the library load path environment variable. At this point I tried drracket again with no luck - same error.

After browsing documentation and blog posts I came to the conclusion that I might need additional changes to the configuration

This is the configuration code/dictionary set up by nix when installing racket

```scheme
;; generated by unixstyle-install
#hash(
      (doc-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/doc/racket")
      (lib-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/lib/racket")
      (pkgs-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/racket/pkgs")
      (share-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/racket")
      (include-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/include/racket")
      (bin-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/bin")
      (apps-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/applications")
      (man-dir . "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/share/man")
      (absolute-installation? . #t)
      (compiled-file-roots . (same "/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/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))
)

```

What (in) or how do I update the configuration for racket to look at environment load path?

I understand this might be a question that is more nix centric. Attempt to ask a question here because my belief that racket configuration can be updated to use the LD\_LIBRARY\_PATH

Thanks  
-Bhaskar

---

<div class="post-metadata">

### Author: ![maddalab](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/maddalab/32/1274_2.png) [@maddalab](https://racket.discourse.group/u/maddalab)
#### Post date: [July 3, 2023, 4:25pm UTC](https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069/2 "2023-07-03T16:25:07Z")

</div>

Output from racket

```scheme
➜ tspl git:(main) ✗ racket ~/workspace/tspl
Welcome to Racket v8.8 [cs].
> (require setup/dirs)
> (get-lib-search-dirs)
'(#<path:/Users/bhaskar/.local/share/racket/8.8/lib>
  #<path:/nix/store/pa9q13354fhxfalyvcd5hlxk4h2amv4b-racket-8.8/lib/racket>)
>

```

It does not see the `LD_LIBRARY_PATH` env var

```scheme
➜ tspl git:(main) ✗ echo $LD_LIBRARY_PATH ~/workspace/tspl
/nix/store/nhpjadxl9yv549hrdm2944k6mmv652vp-libX11-1.8.4/lib

```

---

<div class="post-metadata">

### Author: ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)
#### Post date: [July 4, 2023, 9:37am UTC](https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069/3 "2023-07-04T09:37:27Z")

</div>

I'm sorry I don't know much about Nix.

There is building guidance at [1&nbsp;Building Racket from Source](https://docs.racket-lang.org/racket-build-guide/build.html)

I hope this helps.

Best regards,  
Stephen

---

<div class="post-metadata">

### Author: ![maddalab](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/maddalab/32/1274_2.png) [@maddalab](https://racket.discourse.group/u/maddalab)
#### Post date: [July 4, 2023, 2:47pm UTC](https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069/4 "2023-07-04T14:47:09Z")

</div>

Thank you. I think it has more to do with how racket looks for dynamic libraries to load. I will take a look a the building from source link.

---

<div class="post-metadata">

### Author: ![maddalab](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/maddalab/32/1274_2.png) [@maddalab](https://racket.discourse.group/u/maddalab)
#### Post date: [July 5, 2023, 2:19pm UTC](https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069/5 "2023-07-05T14:19:18Z")

</div>

I did get to the point that racket found the library using `DYLD_LIBRARY_PATH` but got a memory corruption run time error the version I had of `X11` wasn't right.

At that point I was wasting time on Nix dependencies. I decide to install the from the racket distribution. For anyone who comes after me the Nix package definition for racket needs a lot more work and probably not the right place to start.

---

<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: [July 5, 2023, 3:01pm UTC](https://racket.discourse.group/t/racket-installation-with-nix-newbie/2069/6 "2023-07-05T15:01:34Z")

</div>

Thanks @maddalab for this report. I've made some suggestions for the Nix package maintainers over at [Racket FFI can't find external libraries · Issue #209660 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/issues/209660).
