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

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?

3 Likes

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.

6 Likes

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

3 Likes

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 :slight_smile:

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 :smiley:

2 Likes

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

$ 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.

4 Likes

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.)

Regarding the wording, this would be my suggestion:

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.

Thanks. I've pushed that change.

2 Likes

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

1 Like

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

1 Like