massung
2021-5-24 14:06:46

So, I’m not a Linux expert by a long shot. Hoping someone here can help me w/ a problem as it relates to Racket.

I have a VM instance (ala ec2) that I’ve installed Racket locally on (read: in ~/racket as opposed to /usr/local/). It runs just fine. I’ve also installed a couple side packages using raco successfully as well.

Now, what I want to do is run my little app (a simple web server) as root so I can bind to 0.0.0.0 and port 80. However, when I do sudo /home/jeff/racket/bin/racket ./server.rkt, it dies as the root user doesn’t know where to look for those 3rd party packages that I’ve installed.

Right now, I’m getting around this by just building the program as an executable and then just running that as root, which works fine if there isn’t another option.

Just wondering if there’s some cool sudo tip I’m unaware of (like how to keep the PATH of the calling user) or maybe some racket command-line flag I should be using to let racket know where to find installed packages?


samth
2021-5-24 14:09:15

The easiest fix is to install the packages in “installation scope” instead of “user scope”, so they’re accessible to any user of that Racket install.


samth
2021-5-24 14:09:25

You do that using the -i flag to raco pkg install.


massung
2021-5-24 14:14:28

Yeah, I generally dislike doing that b/c deleting it can be a real PITA. This way, when 8.2 is released, I just delete ~/racket and install the new one over it.


samth
2021-5-24 14:15:03

you mean that in that case, you have to re-install the packages?


massung
2021-5-24 14:16:35

no, I mean just deleting all of 8.1. Maybe it’s different on Linux, but on Windows I cant’ just install 8.1 over 8.0. I have to completely uninstall 8.0 first.


massung
2021-5-24 14:16:52

raco pkg migrate works just fine for packages


samth
2021-5-24 14:18:10

I’m confused. What I’m suggesting is that you install the packages in “installation scope”, which should be in the same place, roughly, as the rest of the racket install


massung
2021-5-24 14:19:21

oh oh oh


massung
2021-5-24 14:19:27

sorry, i completely misunderstood


massung
2021-5-24 14:19:50

I thought you meant to install racket to /usr/local/… (read: “typical installation”)


massung
2021-5-24 14:20:13

I just thought raco did that already by default :slightly_smiling_face:


massung
2021-5-24 14:20:25

okay. ill give that a try. thanks


samth
2021-5-24 14:20:39

by default raco installs things for the current user


massung
2021-5-24 14:23:18

Thanks for the tip


sschwarzer
2021-5-24 15:30:45

Thanks for the update! :+1:

When I entered and submitted my package data, I only got an empty form back, as before the Racket update.

I used the settings: • “Git Repository” (in the dropdown list) • URL (combined from the individual fields): <https://git.sr.ht/~sschwarzer/todo-txt#v0.1.0> . I’m not sure if the URL should start with git+https instead. • “New version”: 0.1.0. I don’t remember if I explicitly clicked on "+ Add new version" right to the field, but I think I didn’t. What’s the semantic difference between the Git tag and the version for “Add new version”? When should I use the latter?


cris2000.espinoza677
2021-5-24 15:37:13

Is this a bug? it throws a “no matching clause” error (match '(abc -n \|hola como estas\| m -n \|otros\|) [`(,@`(,name -n ,nombre) ...) (map list name nombre)]) if i replace the expression to evaluate with something like (abc -n hola ...) then it works, but what i gather from the https://docs.racket-lang.org/reference/match.html?q=match#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29\|reference is that it satisfies (quasiquote ,@qp)I've been thinking of just usingsyntax-parsewith justdatum->syntax`


sschwarzer
2021-5-24 15:44:29

I tried again because I wasn’t sure if I had reloaded the package entry form after the Racket update (in case something had changed in the form’s HTML). This time, I left out the “Add new version” information.

When I clicked “Save changes”, I got the filled form back with “Save failed.” at the page’s top, but without any specific information in the form which field(s) were the problem(s).


mflatt
2021-5-24 15:49:18

You will need to use git+https.

I’m not sure about the rest, but you don’t want to use “Add new version” — unless you want the package server to give a different answer for different Racket clients, in which case the version there is a Racket version. (If I make a PR to change the UI, clarifying that label will be one of the things I include.)


laurent.orseau
2021-5-24 15:51:48

I don’t think that’s a bug. match doesn’t do that kind of matching afaict. syntax-parse would work. But you can also loop of course: (let loop ([e '(abc -n \|hola como estas\| m -n \|otros\|)]) (match e ['() '()] [(list name '-n nombre rst ...) (cons (list name nombre) (loop rst))])) -&gt; '((abc \|hola como estas\|) (m otros))


cris2000.espinoza677
2021-5-24 15:52:30

yeah, i supposed that was the case, thank you


soegaard2
2021-5-24 15:56:34

Are you looking on code from Chez Scheme? In that case, maybe you can use an alternative matcher: https://github.com/soegaard/indiana/blob/master/imatch.rkt


soegaard2
2021-5-24 15:56:53

<http://www.cs.indiana.edu/chezscheme/match/>


soegaard2
2021-5-24 15:57:20

Hmm. That last link is dead - try http://archive.org\|archive.org.


ryanc
2021-5-24 15:59:33

Along the line of cool sudo tricks: sudo capsh --keep=1 --user=jeff --inh=cap_net_bind_service --addamb=cap_net_bind_service -- -c '/home/jeff/racket/bin/racket ./server.rkt' (or something like it) is a way of running your server as jeff but with the capability of binding ports under 1024. A more convenient alternative might be to use setcap to permanently modify your racket executable (or a copy of it) to have that capability. You’d need to be careful with either approach, but in many ways they’re safer than running the server as root. (Warning: this answer is based mostly on googling, not on experience.)


cris2000.espinoza677
2021-5-24 16:02:37

thanks, but I don’t see what I need there


soegaard2
2021-5-24 16:04:00

imatch.rkt is only for porting code that comes from Scheme code that uses the Indiana matcher. Otherwise just ignore it.


soegaard2
2021-5-24 16:05:50

Sorry - I followed your link to the reference - and I see the Indiana matcher is irrelevant. I had simply forgotten that the Racket matcher also has quasitquote and ,@ as patterns.


cris2000.espinoza677
2021-5-24 16:06:09

ah np


capfredf
2021-5-24 16:26:12

maybe this is a bug (or a bug in my understanding of match) &gt; (match '(abc) [`(abc ...) 42]) 42 &gt; (match '(abc) [`(,@(list abc)) 42]) 42 &gt; (match '(abc) [`(,@(list abc) ...) 42]) ; match: no matching clause for '(abc) [,bt for context]


capfredf
2021-5-24 16:30:03

IMO, the behavior of ... in quasipatterns is not consistent, or at least not documented well.


cris2000.espinoza677
2021-5-24 16:32:05

yeah


soegaard2
2021-5-24 16:33:49

Let me see if I get the meaning of (,@(list abc) …) . First ,@(list abc) matches matches a splicing list containing abc. So ( ,@(list abc) ...) matches zero or more "splicing abs"s. ?


soegaard2
2021-5-24 16:34:17

Or simply a list of zero or more abc symbols ?


sschwarzer
2021-5-24 16:46:39

Ok, a new test … Since the dropdown list has only “Git Repository” and “Simple URL”, I selected “Simple URL” and entered git+<https://git.sr.ht/~sschwarzer/todo-txt#v0.1.0> in the text field. When submitting, I got the form back with the message “Save failed.” at the top. Interestingly, the form contains the original Git URL “decoded” (see the screenshots).


greg
2021-5-24 16:52:22

I’m not saying it shouldn’t work, or that you’re wrong to want to do it. But personally I’d avoid mixing quasipatterns and ellipses. It feels like too much cognitive load — at least for my small brain which already has enough material with which to get confused.


soegaard2
2021-5-24 16:54:22

Maybe an (splicing-list pat) would make things simpler?


cris2000.espinoza677
2021-5-24 16:55:42

yeah


sschwarzer
2021-5-24 17:00:44

I think the dropdown list should contain: • Git Repository (Git Protocol) - shown in the wizard with git:// prefix • Git Repository (HTTPS Protocol) - shown in the wizard with git+https:// prefix • Simple URL - no wizard, but a link to the documentation for the requirements. For example, if I remember correctly, a MANIFEST file is needed. By the way, it would be nice to find a more informative term than “Simple URL”, because even though you could say that the URL is “simple”, the respective location needs a MANIFEST file. (I tried finding the information in the docs, but can’t right now. Maybe the MANIFEST is no longer needed?) Do we need any other entries for the dropdown list?


mflatt
2021-5-24 17:28:41

It looks like the “save failed” message was not-so-helpful error reporting for “todo.txt” as a tag. On a hunch that “.” might not be allowed in a tag, I tried adding that tag to one of my packages and got that error.

I was able to use git+<https://git.sr.ht/~sschwarzer/todo-txt#v0.1.0> as a package source and save, but it does show up wrong in the preview. I’ll fix the preview problem, because that belongs with the changes I was trying to make for now.

More changes would be great, but I’ll leave to others at https://github.com/racket/racket-pkg-website .


capfredf
2021-5-24 19:49:40

soegaard2
2021-5-24 19:50:28

Btw there is a pretty new commit on this. My Racket isn’t new enough to test.


capfredf
2021-5-24 19:50:59

Mine is pretty new


capfredf
2021-5-24 19:52:02

Personally I agree with @greg. I wouldn’t use … with quasi-patterns either:sweat_smile:


cris2000.espinoza677
2021-5-24 20:37:04

I don’t know if this should be posted in #general but http://replit.com\|replit.com now lets ppl <https://blog.replit.com/nix|run scripts with nix> allowing to run any language that nix has, and I was wondering if someone knows how to make Racket run on it. (I have no idea what nix is, some package manager? sorry if I interpreted something wrong)


hazel
2021-5-24 20:39:46

in shell.nix: { pkgs ? import &lt;nixpkgs&gt; {} }: pkgs.mkShell { buildInputs = with pkgs; [ racket ]; }


cris2000.espinoza677
2021-5-24 20:40:24

ah, thank you! I’ll try it immeditely


hazel
2021-5-24 20:40:57

trying it rn


hazel
2021-5-24 20:48:08

cris2000.espinoza677
2021-5-24 20:49:30

oohh thank you


cris2000.espinoza677
2021-5-24 20:49:42

how do you modify .replit?


philip.mcgrath
2021-5-24 20:50:40

I strongly recommend running as an unprivileged user with the capability of binding low-numbered ports. I had a dependency with a path-traversal vulnerability once, and this would have saved me a stressful few days. If you use systemd or similar, this can be quite convenient. For example, I have this in /etc/systemd/system/ricoeur-portal.service: [Unit] Description=Digital Ricoeur portal web server [Service] User=ricoeurd Group=ricoeurd AmbientCapabilities=CAP_NET_BIND_SERVICE WorkingDirectory=/home/ubuntu/ricoeur-portal/ ExecStart=/usr/local/bin/ricoeur-portal --production [Install] WantedBy=multi-user.target where /usr/local/bin/ricoeur-portal is a Racket launcher created by raco setup for a package installed in installation scope, and the result serves on ports 80 and 443 at http://digitalricoeur.org\|digitalricoeur.org.


hazel
2021-5-24 20:51:16

I… don’t know, it didn’t show up in the editor as a file for whatever reason


hazel
2021-5-24 20:51:30

I just added the file and added what I needed to it, even though it was blank but it wasn’t in the sidebar


cris2000.espinoza677
2021-5-24 20:51:43

you forked it from one of the examples? i see


hazel
2021-5-24 20:52:22

I have never used this website in an extended capacity, I just know Nix


cris2000.espinoza677
2021-5-24 20:52:46

ah, well, thank you for your help!


mflatt
2021-5-24 23:01:46

The server is changed — hopefully an improvement!