1. 13
  1. 2

    Is there a way to make chicken-install work without root access? Or run xj from source without chicken-install?

    1. 3

      I made a static executable of this, just for grins, and to show how easy it is to do that with chicken. It has no dependencies, not even libc. here’s a link to the executable and here’s a link to the gpg signature.

      It goes without saying, but this is a binary from a rando on the net, so caveat downloader. FWIW my key is on keys.openpgp.org, and it is email-verified.

      To build a static executable if you have all the dependencies installed, the compiler invocation is csc -static -L -static xj.scm. That works on musl, though glibc is known to have issues when statically linked.

      1. 1
        1. Yes, IIRC if you run it as user it installs into home. I don’t have too much experience with this mode.
        2. Yes, run csc xj.scm to compile it once you have the dependencies installed.
        1. 2

          (edited; the initial version of this comment showed a different error before I tried the env var)

          Ah, I got it, there’s an env variable to pass. Now I’m getting this error:

          $ LANG=C CHICKEN_INSTALL_REPOSITORY=$HOME/.local/lib/chicken chicken-install xj
          building srfi-1
            installing srfi-1
          building srfi-14
            installing srfi-14
          building srfi-13
             /usr/bin/csc -host -D compiling-extension -J -s -regenerate-import-libraries -setup-mode -I /home/tmp/.cache/chicken-install/srfi-13 -C -I/home/tmp/.cache/chicken-install/srfi-13 -O3 -d0 srfi-13.scm -o /home/tmp/.cache/chicken-install/srfi-13/srfi-13.so
          Syntax error (import): cannot import from undefined module
          	Expansion history:
          	<syntax>	  (##core#begin (module srfi-13 (check-substring-spec let-string-start+end kmp-step make-kmp-restart-v...
          	<syntax>	  (module srfi-13 (check-substring-spec let-string-start+end kmp-step make-kmp-restart-vector reverse-...
          	<syntax>	  (##core#module srfi-13 (check-substring-spec let-string-start+end kmp-step make-kmp-restart-vector r...
          	<syntax>	  (import (chicken base) (chicken fixnum) (chicken platform) (except (scheme) string-copy string-fill!...	<--
          Error: shell command terminated with non-zero exit status 17920: '/usr/bin/chicken' 'srfi-13.scm' -output-file '/home/tmp/.cache/chicken-install/srfi-13/srfi-13.c' -dynamic -feature chicken-compile-shared -feature compiling-extension -emit-all-import-libraries -regenerate-import-libraries -setup-mode -include-path /home/tmp/.cache/chicken-install/srfi-13 -optimize-level 3 -debug-level 0
          Error: shell command terminated with nonzero exit code
          "sh /home/tmp/.cache/chicken-install/srfi-13/srfi-13.build.sh"

          any idea what is wrong? (I’m running on Debian 11, chicken is installed with apt)

          1. 1

            Thank you for that. Can some Chicken peeps (I know some are on Lobsters) help sort this out?

            1. 1

              The poster specifically seems to have problems building srfi-13.

        2. 1

          The easiest way is to install CHICKEN from sources into a user directory (all you need is make and a C compiler). Put it in $PATH and just call chicken-install with the egg you want.

          The second is to use the CHICKEN_REPOSITORY_PATH environment variable as well as the CHICKEN_INSTALL_REPOSITORY variable. Together this should be enough, but I’ve personally never really used these variables.

          1. 1

            Setting CHICKEN_INSTALL_REPOSITORY and CHICKEN_REPOSITORY_PATH isn’t enough, because chicken-install will try to install executables to /usr/bin. As far as I can tell, there is no way to override that location, either. Maybe this warrants a ticket?

            I use the first method, installing chicken from sources into a user directory, myself.

            1. 1

              I dunno, AFAIK it’s not really supported anyway. CHICKEN is so small and simple to install, it makes more sense to just install it to another location if you’re not willing to install as root. But if you feel strongly about it, feel free to make a ticket.

        3. 2

          Is there a way to browse the code online?

          1. 6

            Here is the source code.

            ;; Copyright 2020 Idiomdrottning.
            ;; This is free software (3-clause BSD, see COPYING for details).
            (import (chicken string) fmt html-parser srfi-1 utf8)
            (define (ws? str)
              (and (string? str)
                   (every char-whitespace? (string->list str))))
            (define (cnw x) (remove ws? (cdr x)))
            (define (as? x)
              (eq? #\* (string-ref (->string x) 0)))
            (define (gtm x)
              (if (or (as? (car x)) (as? (caar x))) (gtm (cnw x)) x))
            (define w (o wrt string-chomp ->string car))
            (define ((i l) st)
              (if (= l (fmt-col st)) st ((cat nl (space-to l)) st)))
            (define (vk x l)
              (cat (w x) #\: (w (cnw x))))
            (define (ob x p lt gt l)
              (cat #\{ (w x) #\: (i (+ 2 l))
                   lt (fmt-join (cute p <> (+ 2 l))
            		    (cnw x) (cat #\, (i (+ 3 l))))
                   gt #\}))
            (define (j x l)
               ((atom? x) (wrt (if (number? x) x (->string x))))
               ((= 1 (length x))
                (if (atom? (car x))
            	(cat #\{ (w x) ": []}")
            	(j (car x) l)))
               ((eq? '@ (car x)) (ob x vk #\{ #\} l))
               (else (ob x j #\[ #\] l))))
            (fmt #t (j (gtm (cnw (html->sxml))) 0 ) nl)
            1. 1

              Oh wow, thanks

          2. 2

            JSON is quite bad choice for markup/documents.

            1. 5

              I am pretty sure the goal isn’t for markup, but for querying HTML documents…

              1. 3

                Yep! And SVG and all kinds of stuff. It kind of shows how clunky JSON can be when trying to represent a tagged tree.

                1. 1

                  And SVG and all kinds of stuff.

                  Yes, of course. The title calls out HTML specifically. ;)

                2. 2

                  I’d probably just use css selector (or i know other people prefer xpath) for that… I guess if you already know jq though that might make more sense.

                  1. 1

                    Always happy to hear people say that JSON is 100% useless. This project’s purpose is for XML to be usable in contexts that only understands JSON. Which are becoming common in the world of Unix pipes.

                3. 2

                  Yes, I hate JSON. Don’t shoot the messenger.