Hi! Is there a good way to connect from a browser running on Windows to a local jscoq install on WSL2? or should I install jscoq on Windows natively?
When I open examples/scratchpad.html, I see:
Failed to start jsCoq worker.
(Serving from local file;
has --allow-file-access-from-files been set?)
You should ask this question in the jsCoq stream.
Btw.: can I move something to a different stream?
This topic was moved here from #Coq users > windows vs WSL by Théo Zimmermann
@Darij Grinberg I'm not very familiar with windows, but maybe installing npm's http-server
would work?
that's what I use on linux
it's a very simple web server
@Emilio Jesús Gallego Arias any more details? I don't think I've ever successfully installed a server...
If you have python3 installed you can use python3 -m http.server
(which will serve the current directory on port 8000 by default).
ok, what do I do next?
how do I connect? and which directory should I run this in?
I don't know enough about the current jscoq setup to say. I suppose in the parent directory of examples
but that's just a guess. With that setup you should be able to open http://localhost:8000/examples/scratchpad.html and hopefully it will find all the required files.
hmm
i don't think it's working
it definitely connects to the files, but scratchpad.html is empty, and in the other examples files the coq forms are not interactive
and on the linux console, i'm getting stuff like this:
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /ui-js/jscoq-loader.js HTTP/1.1" 200 -
127.0.0.1 - - [07/Jul/2021 16:48:53] code 404, message File not found
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /codemirror/lib/codemirror.css HTTP/1.1" 404 -
127.0.0.1 - - [07/Jul/2021 16:48:53] code 404, message File not found
127.0.0.1 - - [07/Jul/2021 16:48:53] code 404, message File not found
127.0.0.1 - - [07/Jul/2021 16:48:53] code 404, message File not found
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /codemirror/theme/blackboard.css HTTP/1.1" 404 -
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /codemirror/addon/hint/show-hint.css HTTP/1.1" 404 -
127.0.0.1 - - [07/Jul/2021 16:48:53] code 404, message File not found
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /codemirror/theme/darcula.css HTTP/1.1" 404 -
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /codemirror/addon/dialog/dialog.css HTTP/1.1" 404 -
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /ui-css/coq-log.css HTTP/1.1" 200 -
127.0.0.1 - - [07/Jul/2021 16:48:53] code 404, message File not found
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /codemirror/lib/codemirror.js HTTP/1.1" 404 -
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /ui-css/coq-light.css HTTP/1.1" 200 -
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /ui-css/settings.css HTTP/1.1" 200 -
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /ui-css/coq-dark.css HTTP/1.1" 200 -
127.0.0.1 - - [07/Jul/2021 16:48:53] "GET /ui-css/coq-base.css HTTP/1.1" 200 -
I haven't used jscoq in years so I am out of my depth here. Do the files that yield 404 errors exist (relative to the parent directory of examples
)?
Maybe there is some git submodule for codemirror that hasn't been initialized?
ah right
there is no /codemirror at all
this is an npm install IIRC, so i don't see any traces of git in the directory
oh sorry, I thought you had installed jscoq from npm
i have
ah you did? it should be there, but then you need to serve the install directory
I am not familiar with the npm setup a lot, ccing @Shachar Itzhaky
i'm serving node_modules/jscoq; is that wrong?
was "npm install jscoq" too simple?
Should work fine, but indeed I'm not sure what the right directory to point the web server is
hmm
ah!
the entire node_modules needs to be served
thank you! that wasn't very intuitive though :)
Glad it worked, please if you think we can improve the documentation don't hesitate to submit a PR / issue
so now it's missing all packages:
Package 'init' is missing (http://localhost:8000/jscoq/coq-pkgs/init.json: not found (404))
Package 'mathcomp' is missing (http://localhost:8000/@jscoq/mathcomp/coq-pkgs/mathcomp.json: not found (404))
Package 'dsp' is missing (http://localhost:8000/jscoq/coq-pkgs/dsp.json: not found (404))
do i need to compile them first?
or should i just ditch npm and install it from the repo?
Hi. This definitely should work, since our website is built using the package from npm.
Did you try https://github.com/jscoq/jscoq/blob/v8.13/docs/embedding.md? (Actually I have updated this file today, but only the parts related to coqdoc.)
@Shachar Itzhaky Ah, so I should browse to /jscoq/index.html.That looks better. Is there a way to check that it correctly imports packages?
Some simple code snippet?
Try e.g. Require Import Lia.
ah seems to work
or not
Cannot find a physical path bound to logical path matching
suffix <>.
You can also copy the npm-landing.html
to the root of your project and try there.
Looks like it did not find the package files (coq.json etc.) after all :(
this works:
Compute
let n := 33 : nat in
let e := n+n+n in
e+e+e.
= 297 : nat
so the "core", whatever it is, seems to be in place
Oh so it found init but not arith? hmm
did you get any warnings in the message area, on startup?
it actually spent some time loading parts of ssreflects from your command
For Lia? :-s
yeah
maybe the error message was spurious
what's a way to check if it was successful?
ok wait that's super strange. I'm trying to reproduce.
these errors are rarely spurious. But you can try running the rest of the snippet (copy from here: https://coq-next.vercel.app/ci/diagnostics.html)
you're right, it's not spurious
do you have a few minutes to zoom?
wait let me try to run the exact same commands. Doing npm i jscoq
now.
are you on WSL?
that might be causing file access issues
no, but that should not matter in principle since you are not building it. Are you using http-server
to serve the files?
python3 -m http.server
in my node-modules
directory
python 3.7.3, node v10.24.0, jscoq freshly installed yesterday or so
It seemed to work on Linux. Let me try WSL now.
On my local machine npm i jscoq
hangs right now... is my home internet sluggish atm? :D
@Darij Grinberg apart from coq.json
, what is the content of the node_modules/jscoq/coq-pkgs
directory?
darij@moria:/mnt/d/dev/node_modules/jscoq/coq-pkgs$ ll
total 28068
drwxrwxrwx 1 darij darij 4096 Jul 6 20:58 .
drwxrwxrwx 1 darij darij 4096 Jul 6 20:58 ..
-rwxrwxrwx 1 darij darij 10528757 May 21 18:45 coq-arith.coq-pkg
-rwxrwxrwx 1 darij darij 2224820 May 21 18:45 coq-base.coq-pkg
-rwxrwxrwx 1 darij darij 9772640 May 21 18:45 coq-collections.coq-pkg
-rwxrwxrwx 1 darij darij 124012 May 21 18:45 coq.json
-rwxrwxrwx 1 darij darij 4963250 May 21 18:45 coq-reals.coq-pkg
-rwxrwxrwx 1 darij darij 1114758 May 21 18:44 init.coq-pkg
that seems to be it.
Sorry I find that I am unable to offer useful information since I am trying for 20 minutes to complete a npm i jscoq
and it just won't finish up.
weirdly enough npm i wacoq
does work :face_palm:
that seems to be it.
meaning the installer has failed to download all files?
No, I meant that these are the files that should be there.
ah
I have no idea what's going on. I am running wget 'https://registry.npmjs.org/jscoq/-/jscoq-0.13.0.tgz'
and it just stalls forever after downloading 25MB. Is NPM blacklisting me for having installed too many packages today?
Oh ok I have misled you. In the index.html
you actually have to run:
From Coq Require Import Lia.
Sorry! :worried:
I will set implicit_libs: true
in these examples for future versions. It is admittedly confusing to newcomers.
@Shachar Itzhaky Thank you! This works
my next question would be how to install packages (specifically, the dependencies of https://github.com/hivert/Coq-Combi ) and then how to work on a multi-file project
mathcomp is already available; npm i @jscoq/mathcomp
, then you can add 'mathcomp'
to all_pkgs
in the config.
Compiling packages unfortunately still requires that you build jsCoq locally (so that you have a compatible coqc
). We are working on a Docker image that will allow to circumvent this need... but it's not ready yet.
follow https://github.com/jscoq/jscoq/blob/v8.13/docs/build.md. It used to work on WSL; I have not tested it for some time (there is no WSL image in GitHub CI). Notice that you probably need to do a 64-bit build on WSL. Let me know if this works for you.
thanks -- I've now gotten coqide to work, so this has fallen to low priority for me (much as I love the idea of running coq in my browser)
Ok! BTW you can also try VSCoq (Visual Studio Code plugin).
I think that for multi-file project the support in jsCoq may be a bit too bleeding-edge.
Regardless, I have compiled mathcomp.multinomials so probably will be included in future releases.
yeah, I've tried vscoq too, couldn't really get it to work either for a different reason :)
great news about multinomials
I found that there are many other packages under the mathcomp org. I wonder if there is an easy way to make them all available to our users without having to go over them one by one.
Last updated: May 31 2023 at 02:31 UTC