soegaard2
2021-9-14 07:49:26

Yes


heefoo
2021-9-14 11:27:56

@soegaard2 your tool might be helful then


heefoo
2021-9-14 11:28:10

i am using racket to develop a set of tools for differential privacy



soegaard2
2021-9-14 11:33:19

That’s a great write up !


soegaard2
2021-9-14 11:34:15

gknauth
2021-9-14 12:48:08

I voted in both places [http://lobste.rs\|lobste.rs & HN] and saw my vote count.


heefoo
2021-9-14 12:56:33

done


cperivol
2021-9-14 17:03:10

Ist there a way to pass a racket string to subprocess stdin?


cperivol
2021-9-14 17:04:23

when I use open-input-string it complains that it’s not a file-stream-port?


samdphillips
2021-9-14 17:11:17

The subprocess’s stdin will be an output port from Racket.


cperivol
2021-9-14 17:12:40

well open-output-string doesn’t work either for the same reason


samdphillips
2021-9-14 17:13:51

I think you need to use the output port returned from subprocess and write to it


soegaard2
2021-9-14 17:14:04

Wait - how are you using open-input-string and open-output-string? They are used to read and write directly from strings - so as such they are unrelated to subprocess.


samdphillips
2021-9-14 17:14:13

(it’s been a while since I’ve shell scripted in racket)


cperivol
2021-9-14 17:14:33

The code I am trying to run is: (subprocess #f (open-output-string "hello") #f "cat")


cperivol
2021-9-14 17:14:55

or open-input-string , I am not quite sure


samdphillips
2021-9-14 17:15:10

Yeah IIRC you pass #f and it will give you an output port that will be connected to the process stdin


cperivol
2021-9-14 17:16:40

pass #f where?


soegaard2
2021-9-14 17:16:47

Hmm. I’ll try that.


samdphillips
2021-9-14 17:19:26

@cperivol where you passed the open-output-string call


soegaard2
2021-9-14 17:22:22

I thought, this would work: #lang racket (define in (open-input-string "hello")) (define out (open-output-string "my standard out port")) (define err (open-output-string "my error port")) (subprocess out in err "cat") (get-output-string out) But it turns out that out needs to be a file stream port.


cperivol
2021-9-14 17:23:06

@samdphillips is right actually


samdphillips
2021-9-14 17:26:38

(define-values (pr stdout stdin stderr) (subprocess #f #f #f "/bin/cat")) (displayln "hello world" stdin) (flush-output stdin) (read-line stdout)


samdphillips
2021-9-14 17:27:17

I imagine they need to be file stream ports because then it can skip all of the port machinery and just hand the file descriptor to the subprocess.


cperivol
2021-9-14 17:29:34

cool, do you know how I can send end of file?


samdphillips
2021-9-14 17:29:51

Just close the output port


sschwarzer
2021-9-14 17:53:31

@cperivol In a program of mine, I use ;; Markdown-String -> HTML-String ;; ;; Convert Markdown string to HTML string. (define (markdown->html markdown-string) (define output-port (open-output-string)) (parameterize ([current-input-port (open-input-string markdown-string)] [current-output-port output-port]) (define exit-code (system*/exit-code ; If the executable isn't found (result is `#f`), provide a binary name ; so that `system*/exit-code` doesn't fail with a contract violation ; but with the user error below. (or (find-executable-path "pandoc") "pandoc") "--standalone" "--css=../css/mvp_custom.css" "--from=markdown" "--to=html5" ; Write HTML to stdout. "--output=-" ; Read Markdown from stdin. "-")) (when (not (= exit-code 0)) (raise-user-error "pandoc execution failed with exit code" exit-code))) (get-output-string output-port)) I’m not using subprocess here, but system*/exit-code . Maybe you can use system*/exit-code similar to here or apply the pattern to subprocess.


samdphillips
2021-9-14 18:00:49

My rule of thumb is if you are just going to wait on the output (synchronous style) use system* (and friends). If you are going to interact with a process (asynchronous style) use subprocess


samdphillips
2021-9-14 18:01:39

If you need to do something complicated wrap subprocess with abstractions


dan.ml.901
2021-9-14 19:29:11

Does raco make file.rkt try to open the requires mentioned in file.rkt? It seems inconsistent…


sorawee
2021-9-14 19:36:24

Yes


sorawee
2021-9-14 19:37:53

I’m not sure what you mean by “inconsistent”. What is inconsistent?


jestarray
2021-9-14 20:19:07

so im trying to get my executable size small and fully self contained: raco demod cliapp.rkt raco exe --embed-dlls .\cliapp_rkt_merged.zo and although it reduced the size from 57MB to 25MB if fi didnt use demod , it wont work standalone.. ffi-lib: could not load foreign library path: libintl-9.dll system error: The specified module could not be found.; win_err=126 context...: body of '#%mzc:cliapp_rkt_merged these are all of the dependencies its using: libcairo-2.dll* libgmodule-2.0-0.dll* libpangocairo-1.0-0.dll* libeay32.dll* libgobject-2.0-0.dll* libpangoft2-1.0-0.dll* libexpat-1.dll* libgthread-2.0-0.dll* libpangowin32-1.0-0.dll* libffi-6.dll* libharfbuzz-0.dll* libpixman-1-0.dll* libfontconfig-1.dll* libiconv-2.dll* libpng16-16.dll* libfreetype-6.dll* libintl-9.dll* ssleay32.dll* libfribidi-0.dll* libjpeg-9.dll* zlib1.dll* libglib-2.0-0.dll* libpango-1.0-0.dll* ``it uses 2htdp/image among a few things but I have no idea wlhy its includinglibeay32.dll(a library that contains encryption functions which allow for coded communications over networks. ) because this cli program doesnt do any networking... it just slices and manipulates images. edit: ahh, i think its cause 2htdp/image(bitmap/url url)` …

Anyone know how i can get my executable size smaller? I’m already using racket/base and only trying to pull in what i need


dan.ml.901
2021-9-14 21:36:26

I think the inconsistency has to do with Racket 7.9 [bc] vs 8.1 [cs]


dan.ml.901
2021-9-14 21:37:17

Basically, the 8.1 [cs] wouldn’t care if the dependent requires were compiled first but the 7.9 [bc] errored out with a standard-module-name-resolver: collection not found if the dependent require hadn’t been compiled yet.


sorawee
2021-9-14 21:41:27

Interesting. collection not found is usually not an error about whether it’s compiled though. It’s an error whether the package is installed


sorawee
2021-9-14 21:41:45

Perhaps in 8.1 you installed the package, but in 7.9 you did not?


dan.ml.901
2021-9-14 21:43:49

that’s possible, yeah


dan.ml.901
2021-9-14 21:44:26

how do I check?


sorawee
2021-9-14 21:45:23

Try raco pkg show <package-name>


sorawee
2021-9-14 21:45:52

Or actually, when you run it, shouldn’t you also get the collection not found error?


dan.ml.901
2021-9-14 21:45:53

huh, no, it’s not installed on 8.1


sorawee
2021-9-14 21:46:13

What is the collection?


sorawee
2021-9-14 21:46:33

That it complains “collection not found”


dan.ml.901
2021-9-14 21:46:35

i think there may be another issue


dan.ml.901
2021-9-14 21:47:43

i think it’s instead require-ing in outdated .zo files that themselves have bad requires


dan.ml.901
2021-9-14 21:48:10

I’m trying something that’s probably not going to work very well… building .zo files via an external make process.


dan.ml.901
2021-9-14 21:48:21

I think that process will need the full dependencies


sorawee
2021-9-14 21:50:57

OK, that sounds complicated, and I don’t fully understand the situation that you are in. But good luck!


alexharsanyi
2021-9-14 22:54:07

A similar question was asked on the beginners channel a while ago: https://racket.slack.com/archives/C09L257PY/p1630479646033100


jestarray
2021-9-14 22:56:35

yeah, i guess there isnt any other way then unless i remove the dependency on 2htdp image… I guess its not too bad because imagemagick is 34MB