advait.raykar
2020-6-24 15:06:38

I have confusion in the way raco exe works. Now supposing I want to make a standalone executable for this file test.rkt: #lang racket (require portaudio) (displayln "This is a test") Will running raco exe test.rkt suffice, or do I have to somehow tell raco exe about its dependency on a lib, in this case portaudio .

What ends up happening for me when I run the executable is (./test) in collection directories: context...: /Applications/Racket v7.7/collects/racket/private/collect.rkt:26:58: fail '#%embedded:portaudio/portaudio:: [running body] Now, here I am trying to figure what may be the issue, portaudio or my use of raco. Any pointers? Btw, on Mac OS.


samth
2020-6-24 15:10:00

Can you try also using raco distribute after raco exe?


advait.raykar
2020-6-24 15:13:16

You mean just a raco distribute test.rkt?


samth
2020-6-24 15:13:48

I forget the command line, but you can use it with the results of raco exe


advait.raykar
2020-6-24 15:15:03

Yeah, saw docs, am trying. Will update


advait.raykar
2020-6-24 15:18:23

So I ran raco distribute test-dir test This resulted in a directory containing a bin, and a lib folder. I tried running ./test from the bin folder, same result :/


samth
2020-6-24 15:18:53

Ok, then the problem is likely in portaudio


advait.raykar
2020-6-24 15:19:32

Hmm okay, time to do some digging then. I was hoping I was using raco wrong.


advait.raykar
2020-6-24 15:20:24

What could be the issue, certain libs can’t work standalone using raco exe?


samth
2020-6-24 15:20:35

It might be that reporting a bug on portaudio is the right thing. Also, I think @jbclements doesn’t use slack much, so using the mailing list might be more successful


samth
2020-6-24 15:21:00

The issue is likely that portaudio is constructed in such a way that raco exe doesn’t work


sorawee
2020-6-24 15:21:02

portaudio uses FFI which brings all sort of weird things


sorawee
2020-6-24 15:22:25

Actually… I think this might be a simple bug


sorawee
2020-6-24 15:22:29

Let me take a quick look


sorawee
2020-6-24 15:23:59

So, you can see that in the source code of portaudio, (define-runtime-path lib "lib/") appears everywhere


sorawee
2020-6-24 15:24:13

sorawee
2020-6-24 15:24:32

you probably should include the ++lib flag


sorawee
2020-6-24 15:24:42

with an appropriate argument


advait.raykar
2020-6-24 15:27:21

Hmm, I see. I am going to try this and get back here.


sorawee
2020-6-24 15:32:46

Though it looks like the variables defined via define-runtime-path are not really used


sorawee
2020-6-24 15:33:03

Instead, collection-file-path is used directly


sorawee
2020-6-24 15:35:41

I don’t know how these things work too, but:

(collection-file-path "libportaudio.2.dylib" "portaudio" "lib") Seems to indicate that one should be able to (require portaudio/lib), but it’s not. I think this is the crux of the problem.


samth
2020-6-24 15:36:20

Right, that’s not a good way to do things, and won’t work with raco exe


samth
2020-6-24 15:38:58

It might be possible to make things work now using ++lib, as you suggested


sorawee
2020-6-24 15:39:28

I tried that, but it didn’t work. Perhaps I also did something wrong :confused:


advait.raykar
2020-6-24 15:39:39

raco exe ++lib /Users/advait/Library/Racket/7.7/pkgs/portaudio/ test.rkt I tried this, but I get a contract violation create-embedding-executable: contract violation


samth
2020-6-24 15:40:11

You would need to supply the things it is missing using ++lib


advait.raykar
2020-6-24 15:40:37

Ah okay, so these would not be limited to racket files right?


sorawee
2020-6-24 15:41:02

The argument to ++lib should be stuff like portaudio/lib I think.


sorawee
2020-6-24 15:41:07

Not full path iiuc


sorawee
2020-6-24 15:42:06

Would be really nice if the doc at https://docs.racket-lang.org/raco/exe.html gives some examples for how ++lib is used


advait.raykar
2020-6-24 15:44:01

raco exe ++lib portaudio/lib test.rkt This results in get-module-code: no such file: #<path:/Users/advait/Library/Racket/7.7/pkgs/portaudio/portaudio/lib.rkt> So, it is expecting a racket file it looks like :thinking_face:


advait.raykar
2020-6-24 16:32:07

After trying to pass all sorts of permutations of the portaudio library in ++lib, there is no change whatsoever in the error. This is some other issue it looks like


sorawee
2020-6-24 17:01:08

If I were you, I would follow @samth’s advice to send an email to , since @jbclements is likely to see your message there more than here.


maueroats
2020-6-24 18:32:30

(Typed Racket) Is there a way to write tests that check for a certain type signature, or verify that a certain call does or does not check? I’m going change a type signature in existing code so that it is more restrictive, and I would prefer to write a unit test to go along with this change. All of the existing uses are supposed to already obey the more restrictive signature.

I am aware that code will fail to typecheck if my change causes an error. Still, I would prefer to have a test to accompany my change.

I saw assert-typecheck-fail and also the turnstile package (prefer not to bring in this heavyweight just for testing).


samth
2020-6-24 19:42:09

You could just write an expression that uses ann to explicitly write the type down.