
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?

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.

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

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.

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

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.

raco pkg migrate works just fine for packages

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

oh oh oh

sorry, i completely misunderstood

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

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

okay. ill give that a try. thanks

by default raco
installs things for the current user

Thanks for the tip

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?

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 using
syntax-parsewith just
datum->syntax`

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

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

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))]))
-> '((abc \|hola como estas\|) (m otros))

yeah, i supposed that was the case, thank you

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

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


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

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

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

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.

ah np

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

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

yeah

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

Or simply a list of zero or more abc symbols ?

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

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.

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

yeah

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?

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 .


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

Mine is pretty new

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

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)

in shell.nix
: { pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
racket
];
}

ah, thank you! I’ll try it immeditely

trying it rn


oohh thank you

how do you modify .replit
?

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.

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

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

you forked it from one of the examples? i see

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

ah, well, thank you for your help!

The server is changed — hopefully an improvement!