joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.23k stars 139 forks source link

Remote slynk server tries to open local files to load contribs #569

Open rpgoldman opened 1 year ago

rpgoldman commented 1 year ago

Trying to connect to a remote slynk server on a linux box from my Mac laptop I get this error from slynk:

Required module slynk-macrostep but no source file slynk-macrostep found in (/Users/rpg/.emacs.d/lisp/sly/contrib/
                                                                             /Users/rpg/.emacs.d/lisp/sly-asdf/
                                                                             /Users/rpg/.emacs.d/lisp/sly-macrostep/
                                                                             /home/rpg/.emacs.d/lisp/sly/slynk/)

This list of directories is the value of slynk-loader::*load-path*.

Looking at the above, you can see that the list of directories contains three directories for the sly contribs that come from the Mac filesystem (they start with /Users) and one from loading slynk proper (the one that starts with /home).

I believe that the *load-path* is populated as a side-effect of define-sly-contrib and then the invocation of sly-setup, which in turn invokes sly--setup-contribs.

I conjecture that while emacs knows how to translate filenames, using tramp, common lisp (the slynk server) has no corresponding magic applying to its `load-path.

It is possible that it would be easiest to fix this by using ASDF instead of the slynk-loader, but I'm not sure how to do this.

What I did in the debugger was:

(setf *load-path* 
  (mapcar #'(lambda (x) (if (equal (second (pathname-directory x)) "Users") 
                                             (make-pathname :directory (subst "home" "Users" (pathname-directory x) :test 'equal)      
                                                                           :defaults x) x)) 
                 *load-path*))

This almost works, but gives an unknown package error in slynk-macrostep.lisp (no "SLYNK-MACROSTEP" package).

I believe that this goes wrong because the slynk-loader tries to compile only slynk-macrostep instead of ASDF-loading the slynk-macrostep system, which would have first compiled and loaded slynk-macrostep/package.lisp.

I will see about using ASDF as the loading method; maybe that will fix things. I will report back.

Note that I have been using sly-macrostep and sly-asdf from GitHub rather than installing them using Emacs packages. I don't know if that would change anything.

rpgoldman commented 1 year ago

I couldn't figure out how to get slynk to load slynk-macrostep from ASDF, but I did make this work by (yuck) doing the following on the server:

$ cp slynk-macrostep.lisp slynk-macrostep.lisp.orig
$ cat package.lisp collect-macro-forms.lisp slynk-macrostep.lisp.orig > slynk-macrostep.lisp

That makes slynk-macrostep into a one-file system, which can be loaded simply by loading that one file.