jsa-aerial / saite

Interactive document creation for exploratory graphics and visualizations. 咲いて (in bloom). Built on top of hanami vega/vega-lite library with CodeMirror and self hosted ClojureScript
MIT License
138 stars 4 forks source link

Error Installing on W10 / Java 8 #11

Closed joinr closed 5 years ago

joinr commented 5 years ago

I'm trying to test this out on W10, and getting the following error after following the self install instructions on the stand-alone jar:

Enter installation directory [~/.saite]: ~/.saite
Exception in thread "main" java.lang.IllegalArgumentException: character to be escaped is missing
        at java.util.regex.Matcher.appendReplacement(Matcher.java:809)
        at java.util.regex.Matcher.replaceAll(Matcher.java:955)
        at clojure.string$replace.invokeStatic(string.clj:106)
        at clojure.string$replace.invoke(string.clj:75)
        at aerial.fs$replace_re.invoke(fs.clj:18)
        at aerial.fs$fullpath.invoke(fs.clj:40)
        at aerial.aerosaite.core$get_install_dir.invokeStatic(core.clj:84)
        at aerial.aerosaite.core$get_install_dir.invoke(core.clj:76)
        at aerial.aerosaite.core$_main.invokeStatic(core.clj:197)
        at aerial.aerosaite.core$_main.doInvoke(core.clj:179)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at aerial.aerosaite.core.main(Unknown Source)

I don't seem to have visibility on the aerial.aerosaite.core repo, so I can't see what -main is doing. It looks like maybe your filesystem utility support doesn't cover windows (that's my best guess based on the stack trace). Looking at the aerial.fs/fullpath, the one that ships with the saite uberjar is different than the one on the public repo. I looked at the source from the REPL.

The original source uses regexes for matching different separators.

If I monkey patch it from the repl to use literal strings instead of the regex:

(defn fullpath
  "Canonicalize FILESPEC, a string, to a fully qualified file path
   for the native system.  ~ in position one is translated to the
   users home directory path, / and \\ are translated to the file
   separator for the native system."
  [filespec-str]
  (let [^String s (str filespec-str)
        s (replace-re
           (case separator
             "/" "\\"
             "/") separator s)]
    (cond
      (= s "~") (System/getProperty "user.home")

      (.startsWith s "~")
      (str (System/getProperty "user.home")
           (if (= (.charAt s 1) File/separatorChar) "" separator)
           (subs s 1))

      :else s)))

I get a passing result:

aerial.fs=> (fullpath "~/.saite/path/to/glory")
"C:\\Users\\joinr\\.saite\\path\\to\\glory"
jsa-aerial commented 5 years ago

Hmmmm, turns out the real problem is a typo. I had this typo once before (fs/fullpath "~.saite") does the 'right thing' on Linux and Mac OS (despite being bogus), but not on Windows. I even have a proper home-path var that uses (fs/join "~" ".saite") to get proper path across OSes but failed to use it in the get-install-directory function. Magic numbers - Go figure... I am going to cut a new release with the fix and will ping here when ready. If you could try that and report back it would be great!

jsa-aerial commented 5 years ago

OK, it is ready: wget http://bioinformatics.bc.edu/~jsa/aerial.aerosaite-0.2.20-standalone.jar

joinr commented 5 years ago

I still get the same error with the linked jar.

joinr commented 5 years ago

Yea, the problem looks like it's still occuring in fullpath per the original issue. We get into aerial.aerosaite.core/install-saite, and around the last binding of the doseq, where you define the output-file binding

    (doseq [[path uris] (cp/resources (io/resource res))
            :let [uri (first uris) _ (prn :uri uri :path path)
                  relative-path (if (not= path "") (subs path 1) path)
                  output-dir (if (re-find #"/" relative-path)
                               (->> relative-path
                                    fs/dirname
                                    (fs/join saitedir res)
                                    fs/fullpath)
                               (fs/fullpath saitedir))
                  output-file (if (re-find #"/" relative-path)
                                (->> relative-path
                                     (fs/join saitedir res)
                                     fs/fullpath  ;;<-----WE CRAP OUT HERE 
                                     io/file)
                                (->> res (fs/join saitedir)
                                     fs/fullpath io/file))]]
   ...)

On my box it gets to installing the relative-path "Scicloj/nano.clj".

After monkey patching in the aforementioned fullpath fix via

(in-ns 'aerial.fs)
(defn fullpath
  "Canonicalize FILESPEC, a string, to a fully qualified file path
   for the native system.  ~ in position one is translated to the
   users home directory path, / and \\ are translated to the file
   separator for the native system."
  [filespec-str]
  (let [^String s (str filespec-str)
        s (replace-re
           (case separator
             "/" "\\"
             "/") separator s)]
    (cond
      (= s "~") (System/getProperty "user.home")

      (.startsWith s "~")
      (str (System/getProperty "user.home")
           (if (= (.charAt s 1) File/separatorChar) "" separator)
           (subs s 1))

      :else s)))
(in-ns 'aerial.aerosaite.core)

I get further along into the install, and run into a different error (some unexpected nil case and protocol dispatch):

aerial.aerosaite.core=> (install-aerosaite "C:\\Users\\joinr\\.saite")
Creating installation(saite home) directory...
Marking installation directory as saite home
Installing resources...
:uri #object[java.net.URI 0x2fa4888c "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Scicloj/nano.clj"] :path "/Scicloj/nano.clj"
:PATH /Scicloj/nano.clj
:RELATIVE-PATH Scicloj/nano.clj
#object[java.net.URI 0x2fa4888c jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Scicloj/nano.clj] :->> #object[java.io.File 0x121f9c52 C:\Users\joinr\.saite\Docs\Scicloj\nano.clj]
:uri #object[java.net.URI 0x4c4be9d8 "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Scicloj/present.clj"] :path "/Scicloj/present.clj"
:PATH /Scicloj/present.clj
:RELATIVE-PATH Scicloj/present.clj
#object[java.net.URI 0x4c4be9d8 jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Scicloj/present.clj] :->> #object[java.io.File 0x21dd91da C:\Users\joinr\.saite\Docs\Scicloj\present.clj]
:uri #object[java.net.URI 0x433db56d "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Scicloj/example-doc.clj"] :path "/Scicloj/example-doc.clj"
:PATH /Scicloj/example-doc.clj
:RELATIVE-PATH Scicloj/example-doc.clj
#object[java.net.URI 0x433db56d jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Scicloj/example-doc.clj] :->> #object[java.io.File 0xe23af91 C:\Users\joinr\.saite\Docs\Scicloj\example-doc.clj]
:uri #object[java.net.URI 0x1bed61d2 "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Test/mix-server-client.clj"] :path "/Test/mix-server-client.clj"
:PATH /Test/mix-server-client.clj
:RELATIVE-PATH Test/mix-server-client.clj
#object[java.net.URI 0x1bed61d2 jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Test/mix-server-client.clj] :->> #object[java.io.File 0x8a11a19 C:\Users\joinr\.saite\Docs\Test\mix-server-client.clj]
:uri #object[java.net.URI 0x2b85edc7 "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Test/insert-delete-examples.clj"] :path "/Test/insert-delete-examples.clj"
:PATH /Test/insert-delete-examples.clj
:RELATIVE-PATH Test/insert-delete-examples.clj
#object[java.net.URI 0x2b85edc7 jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Docs/Test/insert-delete-examples.clj] :->> #object[java.io.File 0x2bf45b7c C:\Users\joinr\.saite\Docs\Test\insert-delete-examples.clj]
:uri #object[java.net.URI 0x4d682397 "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Data/Nano/rRNA-dist.clj"] :path "/Nano/rRNA-dist.clj"
:PATH /Nano/rRNA-dist.clj
:RELATIVE-PATH Nano/rRNA-dist.clj
#object[java.net.URI 0x4d682397 jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Data/Nano/rRNA-dist.clj] :->> #object[java.io.File 0x444ebefd C:\Users\joinr\.saite\Data\Nano\rRNA-dist.clj]
:uri #object[java.net.URI 0x5364b481 "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Data/Nano/CDS-dist.clj"] :path "/Nano/CDS-dist.clj"
:PATH /Nano/CDS-dist.clj
:RELATIVE-PATH Nano/CDS-dist.clj
#object[java.net.URI 0x5364b481 jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Data/Nano/CDS-dist.clj] :->> #object[java.io.File 0x62ec4146 C:\Users\joinr\.saite\Data\Nano\CDS-dist.clj]
:uri #object[java.net.URI 0x7d3a2459 "jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Data/Nano/unmapped-dist.clj"] :path "/Nano/unmapped-dist.clj"
:PATH /Nano/unmapped-dist.clj
:RELATIVE-PATH Nano/unmapped-dist.clj
#object[java.net.URI 0x7d3a2459 jar:file:/C:/Users/joinr/Documents/aerial.aerosaite-0.2.20-standalone.jar!/Data/Nano/unmapped-dist.clj] :->> #object[java.io.File 0x7d5cbcc9 C:\Users\joinr\.saite\Data\Nano\unmapped-dist.clj]
IllegalArgumentException No implementation of method: :child-resources of protocol: #'cpath-clj.core/ResourceLookup found for class: nil  clojure.core/-cache-protocol-fn (core_deftype.clj:583)

Looks like Nano/unmapped-dist.clj either doesn't exist in resources or otherwise isn't loading as expected, causing the unhandled nil type dispatch for child-resources.

jsa-aerial commented 5 years ago

I had power outages here - just getting back. The fs/fullpath issue is bothering me the most because we hit that quite a ways back and a friend who has a Win10 laptop helped with resolving it. At that time it involved just resolving the home directory to get at the config.edn file - no install at that time. However, he is experiencing a regression on that when simply running the server - not in install mode but as server running against his original .saite dir. So, something really odd is going wrong.

Oh, the other error is because I built that against the wrong resources directory...

jsa-aerial commented 5 years ago

wget http://bioinformatics.bc.edu/~jsa/aerial.aerosaite-0.2.21-standalone.jar

a couple other people have tried this and it does work on Win10

Well - for them...

joinr commented 5 years ago

Self install completed. I manually started server using the same commands in linux-runserver and things worked out. I think this could be a cool stand-alone javafx app if you use the webview (you don't get webgl though currently). thanks.

jsa-aerial commented 5 years ago

I'm not all that familiar with Windows any more - havent' really used it in 15 years or so and don't have access to a Win machine. How did the linux-runserver commands work on Win10? Are you using cygwin?

Also, do you have MKL for Windows working? If so, any chance of giving me a short brief on what the files are and how they need to be setup?

Thanks!

joinr commented 5 years ago

How did the linux-runserver commands work on Win10? Are you using cygwin?

Ah, I meant that I just invoked the java cmd delineated in the script (I saw that you describe it later in the readme). I use git for windows, which bundles Mingw and versions of bash, ssh, grep, etc, with git bash as my primary CLI there (old habit). I could not run the script directly since it wants '/usr/bin/nohup' which doesn't exist for me, but that's a minor modification. It may be useful to just have a powershell script too for windows folks.

Also, do you have MKL for Windows working?

I went through the MKL drill a while back trying to help someone on r/clojure setup their environment to use neanderthal. I ended up triangulating a folder with dlls discussion here, maybe that helps. It's a big download though.

jsa-aerial commented 5 years ago

OK, I downloaded your mklite.7z - it looks similar in size to what I have for Mac and Linux. Are these the 64bit libraries?

The part I am totally clueless on is setting up the path or possibly linking to from a standard lib directory to the download unzipped directory of files. On Linux this is simple - just set the LD_LIBRARY_PATH ev; on Mac, even with the new SIP, it is simple because (for reasons I can't fathom) you can link from /usr/local/lib as an ordinary user(!?!?). On Windows it is ????

Actually, I'm not sure you ever got that to work either - from the last part of that discussion it sounded like you could not get Windows to notice the libraries...