Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

live-view! cannot find file #134

Closed
jefffriesen opened this issue Sep 29, 2020 · 5 comments
Closed

live-view! cannot find file #134

jefffriesen opened this issue Sep 29, 2020 · 5 comments

Comments

@jefffriesen
Copy link

Everything seems to be working fine except when I try to live-view! or live-reload!. Here's a screenshot of my setup with oz/view! working. This is a brand new lein app template with no other dependencies except [metasoarous/oz "1.6.0-alpha30"].
Screen Shot 2020-09-29 at 10 15 57 AM

Now when I try to run (oz/live-view! "core.clj") from the repl, I get this error:

; Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
; core.clj (No such file or directory)
[{:file "FileInputStream.java" :line -2 :method "open0" :flags [:java]}
 {:file "FileInputStream.java" :line 213 :method "open" :flags [:java]}
 {:file "FileInputStream.java" :line 155 :method "<init>" :flags [:java]}
 {:file "jar:file:/Users/jeff/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj:229" :fn "fn"  :method "invokeStatic" :flags [:clj]}
 {:file "jar:file:/Users/jeff/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj:229" :fn "fn"  :method "invoke" :flags [:dup :clj]}
 {:file "jar:file:/Users/jeff/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj:69" :fn "fn/G"  :method "invoke" :flags [:clj]}
 {:file "jar:file:/Users/jeff/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj:258" :fn "fn"  :method "invokeStatic" :flags [:clj]}
...

I get the same error whether I use live-view! or live-reload!. I'm using the latest Calva in VSCode. I've watched this video https://www.youtube.com/watch?v=yUTxm29fjT4 and can't see any significant difference in what I'm doing other than the editor and repl.

Is the problem in my setup, this feature or somewhere in between? Thanks

@metasoarous
Copy link
Owner

Hi @jefffriesen. Thanks for posting on this.

You have to specify the complete path to the file. Please try (oz/live-view! "core.clj") and let me know if that works.

Second thing I'll point out is that in notebook mode, you'll probably want to use

[:vega-lite line-plot]

instead of (oz/view! line-plot). The latter will sort of work, but if you end up having multiple documents or other hiccup in there, it'll only show the last call to (oz/view! ...), instead of the whole document. You might have just put that in there to test things working, but just wanted to point that out for others who might come along and read this. That having been said, if I'm refining a visualization in the middle of a big document with a lot of data or heavier computations, I sometimes use (oz/view! ...) and evaluate that single form in my REPL, then replace it with [:vega ...] when I'm ready to look at the whole document again.

I realize this feature is a bit under-documented, and it's probably time I break out the README (which has gotten quite long) into a number of separate documents. Maybe #135 will give me a nicer documentation path...

Anyhow, thanks again for posting, and please let me know if you're able to get that working.

@jefffriesen
Copy link
Author

@metasoarous
I did try (oz/live-view! "core.clj") originally (see screenshot). I tried it again and it didn't work. I also tried variations like src/core.clj, ./src/core.clj and ./core.clj. All with the same error.

Thanks for the tip on using (oz/view! ...) compared to hiccup. I played with it and now I get the difference.

@metasoarous
Copy link
Owner

Oh dear; I flubbed my correction. That should be (oz/live-view! "src/oznotebook/core.clj"). Sorry about that. Please let me know if that works for you.

@metasoarous
Copy link
Owner

One more thing: I noticed you're using Leiningen. One thing to be cautious of is that because Lein compiles namespaces on the classpath greedily on startup, if you put a lot of big data processing operations into your notebooks, that can cause problems. In theory, this shouldn't be a problem with clj/clojure tooling (+ deps.edn). In practice though, I generally put my notebooks in a separate directory anyway, something like notebooks. Depending on your tooling (not sure with Calva), you may have to run (oz/live-view! ...) to load up the namespace before you're able to use your editor's code evaluation features (with vim-fireplace at least, it will complain if you try to evaluate code before running live-view! or an equiv. since it ends up trying to look for the file on classpath first; not sure with Calva or other tooling).

@jefffriesen
Copy link
Author

@metasoarous (oz/live-view! "src/oznotebook/core.clj") worked. Thanks. Also, thanks for more context on using Leiningen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants