Help starting server in sbcl-shen

125 views
Skip to first unread message

emum

unread,
Dec 4, 2021, 6:52:54 PM12/4/21
to Shen
Continuing from a previous post, I have tried adding the following to install.lsp for both, S31.01 and S31.02,

(SETF *stinput* *TERMINAL-IO*)
(SETF *stoutput* *TERMINAL-IO*)
(SETF *sterror* *TERMINAL-IO*)
(DEFUN shen.char-stinput? (Stream)
  (IF (EQ Stream *stinput*) 'true 'false))
(SETF *release* 1.0)
(shen.shen)

I tried both, adding to the top of the install script (right under the copyright) and at the bottom (right above #+CLISP (BYE)).

When it's at the bottom, installation completes, but when it's at the top, I get these errors and installation fails. When installation completes and I try to launch quicklisp using lisp.load or cl.load, it tells me "fn not defined".

What I'm trying to do is use the interop to run quicklisp from Shen, as I can directly from the sbcl repl, in order to launch my hunchentoot server. I'm running sbcl 2.1.7.

Any guidance on how to launch a server in Shen would be appreciated.

Mark Tarver

unread,
Dec 4, 2021, 7:21:48 PM12/4/21
to Shen
You need SBCL 2.0.0 or later.  Copy quicklisp.lisp into the home directory from https://www.quicklisp.org/beta/.   Enter SBCL - type (load "quicklisp.lisp") 
and then (load "install.lsp").

Mark

Message has been deleted
Message has been deleted
Message has been deleted

nha...@gmail.com

unread,
Dec 4, 2021, 7:40:49 PM12/4/21
to Shen
Edit: too many mistakes on the previous post.

For a simple BSD socket example in shen-scheme see this: https://github.com/cisco/ChezScheme/blob/main/examples/socket.ss and https://github.com/cisco/ChezScheme/blob/main/examples/csocket.c

I changed their socket code from AF_UNIX to AF_INET, then in Shen something like this:

(scm.load "socket.scheme")

(define server
  Port -> (let FD (scm.socket)
             (trap-error
              (let  _ (guard (scm.bind FD Port))
                    _ (guard (scm.listen FD 100))
                    P (scm.fd->binary-port (scm.accept FD)) \\ open-fd-input-port

                  (trap-error
                   (let Byte (read-byte P)
                      (do
                       (close P)
                       (scm.close FD)
                       Byte))

                   (/. E (do (close P)
                             (simple-error (error-to-string E))))))

              (/. E (do (scm.close FD)
                        (simple-error (error-to-string E)))))))

emum

unread,
Dec 4, 2021, 8:28:10 PM12/4/21
to Shen
Dr. Tarver, 

> You need SBCL 2.0.0 or later.

Yes, I'm running sbcl 2.1.7. 

> Copy quicklisp.lisp into the home directory from https://www.quicklisp.org/beta/.   Enter SBCL - type (load "quicklisp.lisp") 
and then (load "install.lsp").

Just to clarify, so that I'm not trying every permutation of the steps
  1. When you say (load "quicklisp.lisp") , do you mean (load "~/quicklisp/setup.lisp")? Acc. to their docs under section "Loading After Installation", it should be the latter? I'm getting an error otherwise.
  2. For (load "install.lsp") — do I still need to add the block in my original post here or no? And if so, in what position? At the top or bottom?
  3. Should this work with versions S31.01 and S31.02 downloaded from the downloads page? Or is a particular version needed?
  4. Just to confirm, the idea is that I'm launching quicklisp first and then running the install.lsp script for Shen from quicklisp?

Mark Tarver

unread,
Dec 5, 2021, 8:30:41 AM12/5/21
to Shen
Download https://shenlanguage.org/sbcl-shen.exe which has quicklisp in it.

Mark

emum

unread,
Dec 5, 2021, 1:13:06 PM12/5/21
to Shen
And sorry, what do I do with sbcl-shen.exe once I download it? I'm trying to run it with $ ./sbcl-shen.exe and get "bash: sbcl-shen.exe: command not found". Is this an image I can start the repl with? Or what do I do with it?

Mark Tarver

unread,
Dec 5, 2021, 1:18:02 PM12/5/21
to qil...@googlegroups.com
its a windows executable

M.

On Sun, Dec 5, 2021 at 6:13 PM emum <emum...@gmail.com> wrote:
And sorry, what do I do with sbcl-shen.exe once I download it? I'm trying to run it with $ ./sbcl-shen.exe and get "bash: sbcl-shen.exe: command not found". Is this an image I can start the repl with? Or what do I do with it?

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/qilang/72412b3e-013b-4bd2-b10f-ac42e25e431bn%40googlegroups.com.

emum

unread,
Dec 5, 2021, 2:21:34 PM12/5/21
to Shen
Oh, I'm testing this for localhost on macos, and would eventually deploy on linux. Is there an alternative for those systems that has quicklisp preloaded?

Bruno Deferrari

unread,
Dec 5, 2021, 2:26:34 PM12/5/21
to qil...@googlegroups.com
emum, what didn't work for you using Mark's instructions in the first reply to this thread?

I did this (from S31's directory):

$ wget https://beta.quicklisp.org/quicklisp.lisp
$ sbcl

Then in SBCL's REPL:

* (quicklisp-quickstart:install)
* (load "install.lsp")

And that produces a sbcl-shen.exe binary that should contain quicklisp in it too.

I assume these are the steps Mark followed to produce that Windows binary too.

On Sun, Dec 5, 2021 at 4:21 PM emum <emum...@gmail.com> wrote:
Oh, I'm testing this for localhost on macos, and would eventually deploy on linux. Is there an alternative for those systems that has quicklisp preloaded?

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.


--
BD

Bruno Deferrari

unread,
Dec 5, 2021, 2:27:14 PM12/5/21
to qil...@googlegroups.com
On Sun, Dec 5, 2021 at 4:26 PM Bruno Deferrari <uti...@gmail.com> wrote:
emum, what didn't work for you using Mark's instructions in the first reply to this thread?

I did this (from S31's directory):

$ wget https://beta.quicklisp.org/quicklisp.lisp
$ sbcl

Then in SBCL's REPL:


Sorry, before the "(quicklisp-quickstart:install)" command I missed a '(load "quicklisp.lisp")'
 
* (quicklisp-quickstart:install)
* (load "install.lsp")

And that produces a sbcl-shen.exe binary that should contain quicklisp in it too.

I assume these are the steps Mark followed to produce that Windows binary too.

On Sun, Dec 5, 2021 at 4:21 PM emum <emum...@gmail.com> wrote:
Oh, I'm testing this for localhost on macos, and would eventually deploy on linux. Is there an alternative for those systems that has quicklisp preloaded?

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/qilang/a80bb1f5-0075-41a0-81ff-5894e2b77bc9n%40googlegroups.com.


--
BD


--
BD

emum

unread,
Dec 5, 2021, 3:23:31 PM12/5/21
to Shen
Appreciate the instructions. Ok I got the image dump now from that. So now my final question on this:

In order to launch hunchentoot, what I'm able to do from the sbcl repl is
  1. sbcl repl
  2. (load "~/quicklisp/setup.lisp")
  3. (ql:quickload "hunchentoot")
  4. (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242))
  5. and now a default stock page that hunchentoot ships with is accessible on http://127.0.0.1:4242/
How do I use the interop to launch this from within Shen?

(3-) (ql:quickload "hunchentoot") fn: ql is undefined (4-) (lisp.ql:quickload "hunchentoot") fn: lisp.ql is undefined (5-) (cl.ql:quickload "hunchentoot") fn: cl.ql is undefined

Mark Tarver

unread,
Dec 5, 2021, 6:14:47 PM12/5/21
to qil...@googlegroups.com
you are better placing the commands in a file in uppercase and using (LOAD <Filename>).

M.

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.

emum

unread,
Dec 5, 2021, 7:05:24 PM12/5/21
to Shen
Running directly in repl, I get

(0-) (LOAD "~/quicklisp/setup.lisp")
While evaluating the form starting at line 1, column 0
  of The variable #:ql-setup is unbound.

Then also tried loading the following in a .shen file

(LOAD "~/quicklisp/setup.lisp")
(QL:quickload "hunchentoot")
(HUNCHENTOOT:start (MAKE-INSTANCE 'hunchentoot:easy-acceptor :port 4242))

I get the same error.

Bruno Deferrari

unread,
Dec 5, 2021, 7:23:53 PM12/5/21
to qil...@googlegroups.com
What you have to LOAD in uppercase, and with the code in the file in uppercase is any extra common lisp code you want to run, but that is after following the instructions I gave you before. You cannot type common lisp code into Shen's REPL, but you can call common lisp's LOAD to load it.

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.

emum

unread,
Dec 5, 2021, 7:45:18 PM12/5/21
to Shen
Sorry, I'm confused :( Right now, here is exactly what I have in my shen file

(load "~/quicklisp/setup.lisp")
(ql:quickload "hunchentoot")
(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242))

and then I run (load "test.shen") and get a syntax error. I also tried

(LOAD "~/quicklisp/setup.lisp")
(QL:quickload "hunchentoot")
(HUNCHENTOOT:start (MAKE-INSTANCE 'hunchentoot:easy-acceptor :port 4242))

but got the error I referenced before.

I've also tried prefixing everything with lisp. as well as cl.

If possible, can you please show me exactly what I need in my file and what exactly I need to run in the repl to make this work?

Bruno Deferrari

unread,
Dec 6, 2021, 9:28:48 AM12/6/21
to qil...@googlegroups.com
Sorry, but I don't have the exact commands, and to figure them out I would have to spend quite a bit of time that I don't have right now. 

I can just give you hints related to how Shen handles things, but you will need somebody that is far more familiar with Common Lisp than I am to help you here with the common lisp specific parts.

One thing is that unlike the github version, S31 modifies common lisp's readtable, so when your code there then tries to load more lisp code, it will fail because it is all in lowercase while the readtable expects it to be in uppercase.

The two options I see is for you to figure out how to restore the normal read table before loading more lisp code (that is, something you will have to do in your ".lisp" file that you load from Shen), and then back to what Shen needs at the end.

The other option is for you to try the process using the github version (except "boot.lsp" is used instead of "install.lsp"), in which case you will not have to mess with the readtable.
 

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.

Bruno Deferrari

unread,
Dec 6, 2021, 9:34:13 AM12/6/21
to qil...@googlegroups.com
Forgot this example of adjusting the readtable using your file:

;; This sets the readtable to uppercase everything so that 
;; lowercase code loads correctly
(SETF (READTABLE-CASE *READTABLE*) :UPCASE) 
;; Start of your code
(LOAD "~/quicklisp/setup.lisp")
(QL:QUICKLOAD "hunchentoot")
(HUNCHENTOOT:START (MAKE-INSTANCE 'HUNCHENTOOT:EASY-ACCEPTOR :PORT 4242))
;; Restore the readtable to what S31 uses
(SETF (READTABLE-CASE *READTABLE*) :PRESERVE))
--
BD

Mark Tarver

unread,
Dec 6, 2021, 11:57:53 AM12/6/21
to qil...@googlegroups.com
He might be better off loading all the Lisp he wants into SBCL before installing Shen.  In that way any errors from QuickLisp and Hutchentoot 
are isolated.

This is SBCL 2.0.0, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.

WARNING: the Windows port is fragile, particularly for multithreaded
code.  Unfortunately, the development team currently lacks the time
and resources this platform demands.
* (load "quicklisp.lisp")

  ==== quicklisp quickstart 2015-01-28 loaded ====

    To continue with installation, evaluate: (quicklisp-quickstart:install)

    For installation options, evaluate: (quicklisp-quickstart:help)

T
* (LOAD "~/quicklisp/setup.lisp")
T
* (QL:QUICKLOAD "hunchentoot")
To load "hunchentoot":
  Load 1 ASDF system:
    hunchentoot
; Loading "hunchentoot"
[package impl-specific-gray]......................
[package trivial-gray-streams]....................
[package chunga]..................................
[package cl-base64]...............................
[package alexandria]..............................
[package alexandria-2]............................
[package bordeaux-threads]........................
[package cl-fad]..................................
[package path]....................................
[package cl-ppcre]................................
..................................................
[package flexi-streams]...........................
..................................................
..................................................
..................................................
[package babel-encodings].........................
[package babel]...................................
..................................................
[package cffi-sys]................................
[package cffi]....................................
..................................................
[package cffi-features]...........................
[package cl+ssl/config]...........................
[package trivial-garbage].........................
[package split-sequence]..........................
[package usocket].................................
[package cl+ssl]
debugger invoked on a CFFI:LOAD-FOREIGN-LIBRARY-ERROR in thread
#<THREAD "main thread" RUNNING {10010B0523}>:
  Unable to load any of the alternatives:
   ("libcrypto-1_1-x64.dll" "libeay32.dll")

Mark







emum

unread,
Dec 6, 2021, 3:07:01 PM12/6/21
to Shen
Test case #1

Unzip S31.02
cd into S31.02 directory
Add following to top of install.lisp --- the last line already exists in the script. I removed the duplicate.

;; This sets the readtable to uppercase everything so that 
;; lowercase code loads correctly
(SETF (READTABLE-CASE *READTABLE*) :UPCASE) 
;; Start of your code
(LOAD "~/quicklisp/setup.lisp")
(QL:QUICKLOAD "hunchentoot")
(HUNCHENTOOT:START (MAKE-INSTANCE 'HUNCHENTOOT:EASY-ACCEPTOR :PORT 4242))
;; Restore the readtable to what S31 uses
(SETF (READTABLE-CASE *READTABLE*) :PRESERVE)

Here is the error

Can't save image with more than one executing threadWhile evaluating the form starting at line 105, column 0
  of #P"/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp":

debugger invoked on a SB-IMPL::SAVE-ERROR in thread
#<THREAD "main thread" RUNNING {10015401B3}>:
  Could not save core.
See also:
  The SBCL Manual, Node "Saving a Core Image"

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY   ] Retry EVAL of current toplevel form.
  1: [CONTINUE] Ignore error and continue loading file "/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp".
  2: [ABORT   ] Abort loading file "/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp".
  3:            Exit debugger, returning to top level.

(SAVE-LISP-AND-DIE "sbcl-shen.exe" :TOPLEVEL |shen.shen| :EXECUTABLE T :SAVE-RUNTIME-OPTIONS NIL :PURIFY #<unused argument> :ROOT-STRUCTURES NIL :ENVIRONMENT-NAME #<unused argument> :COMPRESSION NIL)



Test case #2

Downloaded shen-cl-v3.0.3-sources.tar.gz
unzip, cd into directory
sbcl -> (load "boot.lsp")
This did not dump the image for me, although it looks like the installation was successful



Test case #3 -- Dr. Tarver's recommendation to load the sbcl code first

unzippeed S31.02 again
cd into directory
launched hunchentoot
(load "install.lsp")

I get the following error

; compilation finished in 0:00:00.015
Can't save image with more than one executing threadWhile evaluating the form starting at line 98, column 0
  of #P"/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp":

debugger invoked on a SB-IMPL::SAVE-ERROR in thread
#<THREAD "main thread" RUNNING {10015401B3}>:
  Could not save core.
See also:
  The SBCL Manual, Node "Saving a Core Image"

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY   ] Retry EVAL of current toplevel form.
  1: [CONTINUE] Ignore error and continue loading file "/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp".
  2: [ABORT   ] Abort loading file "/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp".
  3:            Exit debugger, returning to top level.

(SAVE-LISP-AND-DIE "sbcl-shen.exe" :TOPLEVEL |shen.shen| :EXECUTABLE T :SAVE-RUNTIME-OPTIONS NIL :PURIFY #<unused argument> :ROOT-STRUCTURES NIL :ENVIRONMENT-NAME #<unused argument> :COMPRESSION NIL)

Mark Tarver

unread,
Dec 6, 2021, 3:11:43 PM12/6/21
to Shen

Could not save core.
See also:
  The SBCL Manual, Node "Saving a Core Image"

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY   ] Retry EVAL of current toplevel form.
  1: [CONTINUE] Ignore error and continue loading file "/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp".
  2: [ABORT   ] Abort loading file "/Users/foo/Documents/bar/bar-Shen/S31.02/install.lsp".
  3:            Exit debugger, returning to top level.

(SAVE-LISP-AND-DIE "sbcl-shen.exe" :TOPLEVEL |shen.shen| :EXECUTABLE T :SAVE-RUNTIME-OPTIONS NIL :PURIFY #<unused argument> :ROOT-STRUCTURES NIL :ENVIRONMENT-NAME #<unused argument> :COMPRESSION NIL)

You are trying to overwrite a Shen image while running it in another window.

Mark

emum

unread,
Dec 6, 2021, 7:57:27 PM12/6/21
to Shen
How do I avoid doing that? I wasn't running anything in another window. It was a freshly unzipped S31.02 package and newly started sbcl terminal. I don't believe I was running shen or sbcl anywhere else.

Mark Tarver

unread,
Dec 7, 2021, 4:18:35 AM12/7/21
to qil...@googlegroups.com
You need to install quicklisp and hutchentoot before Shen.  If you have a problem with the former
that's really a Common Lisp problem and perhaps you need StackOverflow or the Common Lisp group.

Mark

On Tue, Dec 7, 2021 at 12:57 AM emum <emum...@gmail.com> wrote:
How do I avoid doing that? I wasn't running anything in another window. It was a freshly unzipped S31.02 package and newly started sbcl terminal. I don't believe I was running shen or sbcl anywhere else.

--
You received this message because you are subscribed to the Google Groups "Shen" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qilang+un...@googlegroups.com.

emum

unread,
Dec 7, 2021, 12:15:39 PM12/7/21
to Shen
Ok so just to clarify, is the recommendation
  1. Uninstall hutchentoot
  2. Remove quicklisp
  3. delete my Shen package
  4. launch sbcl
  5. install quicklisp
  6. ql install hutchentoot
  7. install Shen
Is that correct? Are any changes needed to any script for this?

Mark Tarver

unread,
Dec 7, 2021, 12:18:01 PM12/7/21
to Shen
Just start with a clean SBCL image 2.0 or higher and see if you can install quicklisp and hutchentoot.
No need to uninstall anything.  If so installing Shen should be easy.

M.

Reply all
Reply to author
Forward
0 new messages