How can I make a little snippet for SPIRAL that does a require/load rather than eval current buffer? (eval current buffer loses line info)
@ghadi not sure I understand the question
blind guess: spiral is not setting file/line info before eval
hey @volrath. I'm really enjoying SPIRAL. Is spiral-eval-buffer calling (require 'foo) or (load "foo") or is it feeding the contents of the buffer to the REPL?
spiral-eval-buffer
uses clojure.lang.Compiler/load
https://github.com/Unrepl/spiral/blob/master/tools/src/spiral/tools/load_file.clj
it sends the whole file content, the file name and path to that function
I see. Yeah if I call it, and then the code later throws an exception, the line/file info is missing/wrong
sorry, words: if I eval-buffer, then my code throws an exception, line/file info is lost
Need more caffeine.
haha, let me try to reproduce
hmm, I tried this:
(ns spiral.connect)
(/ 1 0)
spiral-eval-buffer
on that raises:
Unhandled Exception
java.lang.ArithmeticException: Divide by zero
clojure.lang.Compiler$CompilerException: java.lang.ArithmeticException: Divide by zero, compiling:(connect.clj:3:1)
Numbers.java: 163 - clojure.lang.Numbers/divide
Numbers.java: 3833 - clojure.lang.Numbers/divide
/home/volrath/projects/tests/spiral-tests/src/spiral_tests/connect.clj: 3 - spiral.connect$eval1304/invokeStatic
/home/volrath/projects/tests/spiral-tests/src/spiral_tests/connect.clj: 3 - spiral.connect$eval1304/invoke
Compiler.java: 7062 - clojure.lang.Compiler/eval
Compiler.java: 7514 - clojure.lang.Compiler/load
load_file.clj: 9 - spiral.tools.load_file$load_file_code/invokeStatic
load_file.clj: 4 - spiral.tools.load_file$load_file_code/invoke
unrepl-session: 7 - user$eval1292/invokeStatic
unrepl-session: 7 - user$eval1292/invoke
...
seems to be correct, I think
🤦
Let me try to reproduce your reproduction
yeah, seems correct. Thanks for the sanity check
alright cool, let me know either way if you find the solution to your problem... you could also try to load the file in a regular repl, just to discard unrepl/spiral completely
@cgrand ever done authentication in socket server during repl :init
?
I had a socket server exposed to the internet:
(defn check-auth
[secret]
(when-not (= secret (edn/read))
(println "go away")
(throw (Exception. "Unauthenticated"))))
(defn repl
[]
(check-auth :MAGICVALUE)
(clojure.main/repl
:init #(in-ns 'user)
:read clojure.core.server/repl-read))
@ghadi why not ssh?
could do that, but I have it in a remote docker container, was trying to avoid a sidecar process
but if you really really want to you could use a special accept fn and add your secret at the start of the blob (BYOB ftw)
I strongly discourage pursuing such an endeavor 🙂
(require '[net.cgrand.xforms :as x]
'[clojure.string :as str]
'[jsonista.core :as j]
'[clojure.pprint :refer [pprint] :rename {pprint p*}]
'[<http://clojure.java.io|clojure.java.io> :as io] :reload-all)
~ Unhandled Exception
java.lang.IllegalArgumentException: argument type mismatch
clojure.lang.Compiler$CompilerException: java.lang.IllegalArgumentException: argument type mismatch, compiling:(jsonista/core.clj:1:1)
NativeMethodAccessorImpl.java: -2 - sun.reflect.NativeMethodAccessorImpl/invoke0
NativeMethodAccessorImpl.java: 62 - sun.reflect.NativeMethodAccessorImpl/invoke
DelegatingMethodAccessorImpl.java: 43 - sun.reflect.DelegatingMethodAccessorImpl/invoke
Method.java: 497 - java.lang.reflect.Method/invoke
NO_SOURCE_FILE: 397 - unrepl.replG__1676$classloader$fn__1932/invoke
nil: -1 - unrepl.replG__1676.proxy$java.lang.ClassLoader$ff19274a/findClass
ClassLoader.java: 424 - java.lang.ClassLoader/loadClass
nil: -1 - unrepl.replG__1676.proxy$java.lang.ClassLoader$ff19274a/loadClass
ClassLoader.java: 411 - java.lang.ClassLoader/loadClass
DynamicClassLoader.java: 77 - clojure.lang.DynamicClassLoader/loadClass
might this be unrepl
or spiral
?
unrepl but should be fixed; running latest spiral?
New project https://github.com/Unrepl/ssh-repl
Right now it’s a placeholder but of someone wants to step in, I can provide a master plan
@cgrand latest spiral as of two days ago
currently I use spiral
over ssh tunnels
tunnels built at command line
@gcast ^^^
What's melpa latency?
it used to be really quick (a minute or so) but a few weeks ago I noticed it would take a couple of hours to update. I don't know if it was a circumstantial anomaly or that's the way it is now
you can check out here: https://melpa.org/#/spiral when version changes to 20180125.XXXX, the latest changes are up
although a most reliable way would be to check within emacs, cause maybe the latency is in their website. tbh, I don't know
Melpa advertises its build time fwiw - right now it says "Current build started: an hour ago, last took 3 hours"