# How to package non-racket files into racket binary

**URL:** <https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667>\
**Category:** Questions & Answers\
**Created:** [February 7, 2022, 4:59pm UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667 "2022-02-07T16:59:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [February 7, 2022, 4:59pm UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/1 "2022-02-07T16:59:57Z")

</div>

The problem I actually facing is I write a compiler in Racket but the runtime is written in C, I write

```scheme
(parameterize ([current-directory "./runtime"])
    (match-define (list stdout stdin status stderr do)
      (process "cc start.c runtime.c /tmp/generated.s"))
    (do 'wait)
    (read stdout)))

```

Now the executable generated by `raco exe main.rkt` must be at the path where `runtime` is located.

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [February 7, 2022, 10:02pm UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/2 "2022-02-07T22:02:25Z")

</div>

Actually, I think your problem may be even bigger than this, I'm guessing that the "runtime" subdirectory will have to be located relative to whatever the current directory is when the program is run.

In general, I would avoid the use of `.` as a directory specifier. Instead, I would steer you toward using solutions like `define-runtime-path` to locate resources relative to a particular source file.

A caveat here is that I don't often use `raco exe`, but I conjecture that `define-runtime-path` can also be made to work in this situation, and is the "right" way to do things.

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [February 7, 2022, 10:17pm UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/3 "2022-02-07T22:17:43Z")

</div>

In addition to what @jbclements recommends RE: `define-runtime-path`, you could consider statically compiling the runtime and binary together and giving the result to the user; it should be portable modulo architecture and shared libs.

> [@jbclements](#):
>
> A caveat here is that I don't often use `raco exe` , but I conjecture that `define-runtime-path` can also be made to work in this situation, and is the "right" way to do things.

I believe that `define-runtime-path` is designed to (also) co-operate with `raco exe`.

---

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [February 8, 2022, 2:20am UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/4 "2022-02-08T02:20:09Z")

</div>

Does the following change is what you mean?

```scheme
(define-runtime-path runtime "runtime")
(parameterize ([current-directory runtime])
  ...)

```

Or path should be `(normalize-path "runtime")`? Since the above code didn't work. Thanks!

UPDATE  
Oops, `normalize-path` works the same as didn't use it.

---

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [February 8, 2022, 2:24am UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/5 "2022-02-08T02:24:45Z")

</div>

Yes, this is a way too, but I'm looking for the packaging like game binary or something like that here I think. Thanks~

---

<div class="post-metadata">

**Author:** ![dstorrs](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dstorrs](https://racket.discourse.group/u/dstorrs)\
**Post date:** [February 9, 2022, 5:05pm UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/6 "2022-02-09T17:05:19Z")

</div>

> [@dannypsnl](#):
>
> Does the following change is what you mean?
> 
> ```scheme
> define-runtime-path runtime "runtime")
> (parameterize ([current-directory runtime])
> ...)
> 
> ```

Could you clarify what you mean by 'didn't work'?

For the record, here's what I get when I run a similar code snippet:

In file /Users/dstorrs/test.rkt

```scheme
#lang racket
(require racket/runtime-path)
(define-runtime-path here ".")
(define-runtime-path runtime "runtime")
(define bob-homedir (build-path here 'up "bob")
(println here)
(println runtime)
(println bob-homedir)
(parameterize ([current-directory bob-homedir])
  (println (current-directory)))

```

Output is:

```scheme
#<path:/Users/dstorrs/.>
#<path:/Users/dstorrs/runtime>
#<path:/Users/dstorrs/./../bob>
#<path:/Users/bob/>

```

---

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [February 10, 2022, 4:07am UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/7 "2022-02-10T04:07:44Z")

</div>

I think I have do something wrong(oops). `define-runtime-path` should solve the problem

---

<div class="post-metadata">

**Author:** ![zhangkaizhao](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/zhangkaizhao/32/436_2.png) [@zhangkaizhao](https://racket.discourse.group/u/zhangkaizhao)\
**Post date:** [February 11, 2022, 5:26pm UTC](https://racket.discourse.group/t/how-to-package-non-racket-files-into-racket-binary/667/8 "2022-02-11T17:26:08Z")

</div>

I recommend an article written by Bogdan Popa:

> **[Deploying Racket Web Apps](https://defn.io/2020/06/28/racket-deployment/)**
>
> Someone recently asked about how to deploy Racket web apps on the Racket Slack. The most common answers were
> install Racket on the target machine, then ship your code there or use Docker (basically a “portable” variant of option 1). I wanted to...
