unrepl

discussing specification of an edn-based repl and its implementations.
ghadi 2018-01-25T14:30:49.000571Z

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)

volrath 2018-01-25T14:35:20.000346Z

@ghadi not sure I understand the question

cgrand 2018-01-25T14:37:16.000793Z

blind guess: spiral is not setting file/line info before eval

ghadi 2018-01-25T14:38:30.000021Z

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?

volrath 2018-01-25T14:39:24.000203Z

spiral-eval-buffer uses clojure.lang.Compiler/load

volrath 2018-01-25T14:39:53.000348Z

it sends the whole file content, the file name and path to that function

ghadi 2018-01-25T14:40:27.000130Z

I see. Yeah if I call it, and then the code later throws an exception, the line/file info is missing/wrong

ghadi 2018-01-25T14:41:10.000364Z

sorry, words: if I eval-buffer, then my code throws an exception, line/file info is lost

ghadi 2018-01-25T14:41:15.000227Z

Need more caffeine.

☕ 1
volrath 2018-01-25T14:41:28.000260Z

haha, let me try to reproduce

volrath 2018-01-25T14:44:14.000524Z

hmm, I tried this:

volrath 2018-01-25T14:44:21.000075Z

(ns spiral.connect)

(/ 1 0)

volrath 2018-01-25T14:44:30.000555Z

spiral-eval-buffer on that raises:

volrath 2018-01-25T14:44:56.000062Z

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

volrath 2018-01-25T14:45:17.000794Z

seems to be correct, I think

ghadi 2018-01-25T14:45:26.000442Z

🤦

ghadi 2018-01-25T14:45:43.000579Z

Let me try to reproduce your reproduction

ghadi 2018-01-25T14:49:31.000739Z

yeah, seems correct. Thanks for the sanity check

volrath 2018-01-25T14:51:12.000465Z

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

ghadi 2018-01-25T14:57:24.000540Z

@cgrand ever done authentication in socket server during repl :init?

ghadi 2018-01-25T14:59:17.000552Z

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

cgrand 2018-01-25T15:16:40.000828Z

@ghadi why not ssh?

ghadi 2018-01-25T15:17:55.000927Z

could do that, but I have it in a remote docker container, was trying to avoid a sidecar process

cgrand 2018-01-25T15:24:40.000871Z

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)

cgrand 2018-01-25T15:26:03.000381Z

I strongly discourage pursuing such an endeavor 🙂

gcast 2018-01-25T16:10:08.000224Z

(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

gcast 2018-01-25T16:10:15.000232Z

might this be unrepl or spiral?

cgrand 2018-01-25T16:24:12.000643Z

unrepl but should be fixed; running latest spiral?

cgrand 2018-01-25T16:26:22.000634Z

New project https://github.com/Unrepl/ssh-repl

cgrand 2018-01-25T16:27:15.000310Z

Right now it’s a placeholder but of someone wants to step in, I can provide a master plan

gcast 2018-01-25T16:32:50.000635Z

@cgrand latest spiral as of two days ago

gcast 2018-01-25T16:33:02.001034Z

currently I use spiral over ssh tunnels

gcast 2018-01-25T16:33:12.000258Z

tunnels built at command line

cgrand 2018-01-25T16:47:16.000083Z

@gcast ^^^

cgrand 2018-01-25T17:01:53.000883Z

What's melpa latency?

volrath 2018-01-25T17:03:38.000078Z

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

volrath 2018-01-25T17:05:02.000985Z

you can check out here: https://melpa.org/#/spiral when version changes to 20180125.XXXX, the latest changes are up

volrath 2018-01-25T17:06:17.000342Z

although a most reliable way would be to check within emacs, cause maybe the latency is in their website. tbh, I don't know

j0ni 2018-01-25T20:54:54.000525Z

Melpa advertises its build time fwiw - right now it says "Current build started: an hour ago, last took 3 hours"