[racket] Compilation/create executable question

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Jul 13 12:20:22 EDT 2012

On Fri, Jul 13, 2012 at 11:52 AM, Matt Jadud <jadudm at gmail.com> wrote:
> Hi all,
>
> Danny and Jay put me on the right track with my last question, and
> I've now hacked things together for a project that I'd like to share
> with one or two other people so they can explore the hack as well.
> Specifically, I want to find out if we're on the right track on
> multiple platforms, and it seems to me that the easiest way to
> distribute things would be... to distribute them.
>
> I tried a combination of "raco exe" and the "Create executable"
> command in the GUI (I assume they both do the same thing), and I get
> the following error:
>
> ------------------
> ------------------
> delete-directory: cannot delete directory:
> /var/folders/ws/wsXFjSLbFLS0UH1cMyoJ1U+++TI/-Tmp-/drscheme-tmp-13421939091342193909287/dispatch/lib/plt/dispatch/exts/ert/repos/git/craftoe/ardu-see/racket/.
> (Invalid argument; errno=22)
>
>  === context ===
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:381:28: loop
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:381:28: loop
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:381:28: loop
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:381:28: loop
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:381:28: loop
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:381:28: loop
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:357:4: loop
> /Users/jadudm/apps/Racket521/collects/compiler/distribute.rkt:14:2:
> assemble-distribution7
> ------------------
> ------------------
>
> I haven't dug down into distribute.rkt, but I can if it helps. I can
> also try this on a nightly, and/or I can get a cleaned up version of
> the code into a repository by itself for inspection. Or, perhaps this
> is a common problem that is easily resolved.
>
> My suspicion is that
>
> (require racket/runtime-path)
> (define-runtime-path HERE ".")
>

define-runtime-path instructs 'raco exe' to include the
files/directories in the executable image that it builds and bind the
value (HERE) to whatever path that ends up being. (For example, it may
be a fake path or it may be in something like the OS X Resources
directory.) To do that, it needs to make a copy of the directory/file
when the exe is made. It appears that after it has packaged up that
directory, on your system it can't delete it. I don't know why it
would not be able to.

However, in this case, I believe that define-runtime-path may not be
exactly what you want. (I recall that you needed this because you want
to include some static files in the Web app and they are located in
the same directory as the script.)

If you want to distribute these static files with the Web app, then
you do want it.

If you want the static files to be in the same directory as the exe
(wherever it happens to be installed), then you do not want it and you
need something like $0 in bash, which is (find-system-path 'run-file),
I believe.

Jay

> might be part of the issue. But, perhaps it isn't. Frankly, I don't know.
>
> Cheers,
> Matt
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.