Closed Davorak closed 8 years ago
This means that the shims for base are missing. They should always be linked (since they contain most of the RTS, except the autogenerated parts), so it puzzles me a bit why they aren't here.
Are you sure that your shims repository is ok, under ~/.ghcjs/platform-version/shims
? What does the generated lib.js
and lib1.js
contain when you get the error?
At a glance the shims directory and sub-directories look the same as when I implemented https://github.com/ghcjs/shims/commit/9aa4d69f2eb2e77506ce4564d92f6c842a447607. Noting is obviously missing from memory, nothing has an abnormally small file size. The easiest method for me to check this might just be to build another vm and run the code there.
I used diff on an old lib1.js from when I complied the helloWorld example and they are the same.
While the lib.js does show some difference it is roughly the same size, the one from helloWorld is a few hundred lines shorter, and at least the first few lines of both lib.js where similar.
I have uploaded the associated lib.js: http://textuploader.com/?p=6&id=fBNWU
Let me know if you just want to stash the whole directory in a repo for you to look at.
hmm, odd, your lib.js
contains the google closure library files, included by base.yaml
, but not the base js files from the src
subdir. I can't reproduce it though. Can you check that the src
subdir in shims is accessible, and that it really still works if you remove the line?
by the way, your line that selects the canvas should be:
ctx <- getContext =<< indexArray 0 . castRef =<< select "#theCanvas"
since a JQuery selector behaves like an array, you have to get the first selected out of the array. (I probably have forgotten to update an example somewhere)
There really is a src dir in shims and the files look ok, though I have not compared to a fresh vm.
and that it really still works if you remove the line?
So the reason why the problem seemed so odd is because I was missing a closing >
tag on </script>
right before lib.js was included. Sorry for my typo causing so much confusion. I guess I need to include an html validator into my work flow.
After including the addition of indexArray 0
there are no errors but, nothing is displayed on the canvas and nothing is printed to the console.
@Davorak does the problem still persist?
I just tried reproducing your problem and everything seems to work fine. It also prints "hi".
The code I used:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Diagrams.Prelude hiding (doRender)
import GHCJS.Foreign (indexArray)
import GHCJS.Types (castRef)
import JavaScript.Canvas hiding (Canvas)
import JavaScript.JQuery
import Diagrams.Backend.GHCJS
d :: Diagram Canvas R2
d = circle 1
myRender size ctx dia = renderDia
Canvas
(CanvasOptions (Dims size size) ctx)
(pad 1.1 dia)
main :: IO ()
main = do
ctx <- getContext =<< indexArray 0 . castRef =<< select "#theCanvas" -- without this line it runs the print without a problem
myRender 200 ctx d
print "hi"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script language="javascript" src="lib.js"></script>
<script language="javascript" src="rts.js"></script>
<script language="javascript" src="lib1.js"></script>
<script language="javascript" src="out.js"></script>
</head>
<body>
<canvas id="theCanvas" width=201 height=201>
</canvas>
</body>
<script language="javascript">
h$main(h$mainZCMainzimain);
</script>
</html>
This has been open for 2 years, and any current bugs in GHCJS are likely to be different. Closing; please open a new bug if you have trouble installing the current version.
@bergey - Thank you for the follow up. @co-dan - Sorry that I did not respond at the time.
I am unsure if this is the right place to report this error. Maybe it should go under ghcjs-canvas? Or would it be better posted to the mailing list?
The errors: