# Add a -c "clean" flag to raco make?

**URL:** https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178
**Category:** Questions & Answers
**Tags:** raco
**Created:** [November 21, 2021, 7:07pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178 "2021-11-21T19:07:55Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![badkins](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/badkins/32/99_2.png) [@badkins](https://racket.discourse.group/u/badkins)
#### Post date: [November 21, 2021, 7:07pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/1 "2021-11-21T19:07:55Z")

</div>

Does it make sense to add a -c "clean" flag to `raco make` ?

I just got bit by a confusing issue where a file was happily referencing some exported symbols from another file that had been deleted. I realize I can write my own script to blow away `compiled/` directories, but it seems appropriate to be able to accomplish this with a `raco` command.

Thoughts?

---

<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: [November 22, 2021, 10:12pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/2 "2021-11-22T22:12:47Z")

</div>

One obstacle to a `-c` clean flag is knowing where to stop. Normally `raco make` chases dependencies wherever they go, whether to nearby directories, installed packages, or the main `collects` directory that is part of Minimal Racket.

An alternative possibility is a `raco clean` command that removes `.zo` files in the current directory and subdirectories. That's usually the kind of cleaning I would like to have, where I end up writing `find -name '*.zo' | xargs rm`.

---

<div class="post-metadata">

### Author: ![badkins](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/badkins/32/99_2.png) [@badkins](https://racket.discourse.group/u/badkins)
#### Post date: [November 22, 2021, 10:42pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/3 "2021-11-22T22:42:19Z")

</div>

Yeah, the `find` command is simple enough. I simply have an irrational fear of using `rm` in a recursive manner 🙂

---

<div class="post-metadata">

### Author: ![robby](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robby/32/7_2.png) [@robby](https://racket.discourse.group/u/robby)
#### Post date: [November 23, 2021, 2:50pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/4 "2021-11-23T14:50:28Z")

</div>

Would it make sense to add something to `raco setup` that printed out when it spotted a .zo file without a corresponding rkt file? Or maybe that's what `raco clean` would do; it would accept a collection or a pkg and go looking for such things to delete?

Well, either way I have had my `del-zo` script for a very long time 🙂

---

<div class="post-metadata">

### Author: ![Laurent.O](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/laurent.o/32/18_2.png) [@Laurent.O](https://racket.discourse.group/u/Laurent.O)
#### Post date: [November 24, 2021, 9:49am UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/5 "2021-11-24T09:49:16Z")

</div>

I think having such a raco command would be nice, in particular for users who can use the command line but are not necessarily proficient in it. Calling `rm ...*` can be rightfully scary, and risky. And I could finally get rid of my `raco-clean` command 😃

---

<div class="post-metadata">

### Author: ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)
#### Post date: [December 6, 2021, 3:36pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/6 "2021-12-06T15:36:44Z")

</div>

FWIW, if your code is in a collection / package, you can use `raco setup -c`:

```scheme
$ raco setup -c --pkgs pprint-compact
raco setup: bootstrapping from source...
 triggered by command-line `--clean` or `-c`
...
raco setup: --- cleaning collections ---
raco setup: deleting: in <pkgs>/pprint-compact
raco setup: deleting: in <pkgs>/pprint-compact/scribblings
raco setup: deleting: in <pkgs>/pprint-compact/tests

```

That "bootstrapping from source" is kinda scary though. I don't know why it would require bootstrapping here.

---

<div class="post-metadata">

### Author: ![robby](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robby/32/7_2.png) [@robby](https://racket.discourse.group/u/robby)
#### Post date: [January 1, 2022, 9:21pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/7 "2022-01-01T21:21:51Z")

</div>

That comment means that it is first ignoring .zo files and loading itself directly from source, even if there are (valid-seeming) .zo files actually present. It starts up more slowly when this happens, and there are several different reasons why it might do that, hence this line. Alternative wordings welcome!

(Also, this is some functionality that would be great to have in `raco make` too.)

---

<div class="post-metadata">

### Author: ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)
#### Post date: [February 19, 2022, 10:17am UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/8 "2022-02-19T10:17:35Z")

</div>

Regarding the wording, this would be my suggestion:

```scheme
raco setup: ignoring compiled files, rebuilding from source...
 triggered by command-line `--clean` or `-c`

```

Although I also like the original message, bootstrapping may sound a little bit like it does something way more complicated involving multiple steps.

---

<div class="post-metadata">

### Author: ![robby](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robby/32/7_2.png) [@robby](https://racket.discourse.group/u/robby)
#### Post date: [February 20, 2022, 11:35pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/9 "2022-02-20T23:35:22Z")

</div>

Thanks. I've pushed that change.

---

<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 21, 2022, 4:12pm UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/10 "2022-02-21T16:12:58Z")

</div>

> [@mflatt](#):
>
> That's usually the kind of cleaning I would like to have, where I end up writing `find -name '*.zo' | xargs rm` .

Offtopic, I know, but hopefully forgiveable: `xargs` uses whitespace delineation, which can be problematic with files/directories that have spaces in the name. You're likely better off doing `find -name "*.zo" -delete`

---

<div class="post-metadata">

### Author: ![capfredf](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/capfredf/32/935_2.png) [@capfredf](https://racket.discourse.group/u/capfredf)
#### Post date: [February 25, 2022, 2:25am UTC](https://racket.discourse.group/t/add-a-c-clean-flag-to-raco-make/178/11 "2022-02-25T02:25:18Z")

</div>

This is a good tip. Thanks. My problem with find is it is basically the opposite of KISS.
