Closed jkozlowski closed 9 years ago
Ok, I'll admit that even after this discussion I have no idea what's the status.
As far as I understood, using docker means basically calling cabal
there. In other words, this is as good as using cabal
on bare metal and not using stack at all?
Also, I'm not sure what is the current issue. If that's the ghcjs not working, I believe @kfigiela has a working setup.
I didn't quite get the actual status of the https://github.com/commercialhaskell/stack/tree/337-ghcjs branch. @mgsloan what is there? What's done, what's to be done, what's "unknown" and to be researched?
Ok, I'll admit that even after this discussion I have no idea what's the status.
what is there? What's done, what's to be done, what's "unknown" and to be researched?
This thread is getting long and unwieldy. I've split off a couple of issues to reduce confusion:
1) We need to support building code with ghcjs. The initial code for this is very minimal, and just enables passing in the --ghcjs
flag and nothing else https://github.com/commercialhaskell/stack/issues/748
2) We need to support automatically installing GHCJS, in the same way that installing GHC is automated: https://github.com/commercialhaskell/stack/issues/749 . I'd been hoping that this bit can come after adding support for building code with GHCJS. However, given the issues I've had with getting it setup locally, it might actually be best to get this done first.
As far as I understood, using docker means basically calling cabal there. In other words, this is as good as using cabal on bare metal and not using stack at all?
No, stack is still run inside the docker container. Other than the stack solver
command, I don't think cabal-install is ever run by stack. The benefit of this is that you can use a docker image that already has ghcjs + libraries installed.
Also, I'm not sure what is the current issue. If that's the ghcjs not working, I believe @kfigiela has a working setup.
That's the current issue for me, yes. I am running into the issue described here while booting: https://github.com/ghcjs/ghcjs/issues/374
@ryantrinkle 's try-reflex setup works perfectly. Pretty nifty! As he mentions, I don't see how to directly use the results with stack.
Good news everyone! @kfigiela's instructions for building and booting ghcjs worked, so I spent the last few hours implementing initial stack support.
Things now seem to work decently on the 337-ghcjs branch!
I haven't used this for anything big, so who knows what may be missing. Considering how many people are interested in getting this soon, I figured it's better to push something unpolished for people to play with. If you want to try it out, I've pushed a fork of ghcjs-dom-hello which has a stack.yaml which works with my stack branch.
There are a couple caveats:
ghc-7.10
resolver, as otherwise stack will try to install non-ghcjs versions of ghcjs's boot packages. This means that any dependencies need to specified as fixed versions in extra-deps
. I'm pretty sure we're going to need ghcjs specific stackage snapshots.ghcjs --install-executable
, and committed a change which fixes it to the branch 383-fix-install-executable of my fork (and opened a PR). Without this fix, installing any package with an executable will fail with ghcjs yielding usage information for ghcjs --install-executable
.As I've noted on #748, I've decided to have the resolver specify the GHCJS version. Once that's implemented, there will be no more use-ghcjs
field / flag!
It seems that stack solver
doesn't work with GHCJS…?
Other than that, it does seem that this works for us. Great job, @mgsloan ! Now we shall wait for LTS Haskell for GHCJS and it would be… just awesome :)
@mgsloan, great job! Indeed it does work.
During setting up everything I found some minor issues:
stack ghci
does not work properly. It calls ghc --interactive ...
, but should call ghcjs --interactive ...
. It could be fixed for future compability, as it's now experimental feature of ghcjs (see https://github.com/ghcjs/ghcjs/tree/ghcjsi branch). I used --with-ghc
flag, but it didn't help, but this is another story. I'm using ghcjs with changes merged from ghcjsi branch. This seems to be ghcjs bug (it's ignoring $GHC_PACKAGE_PATH
). However, from what I see in my case this variable has the following value: GHC_PACKAGE_PATH=/Users/kamilfigiela/NewByteOrder/development/nodelab-gui/.stack-work/install/x86_64-osx/ghc-7.10/7.10.2-ghcjs/pkgdb:/Users/kamilfigiela/.stack/snapshots/x86_64-osx/ghc-7.10/7.10.2-ghcjs/pkgdb:/usr/local/Cellar/ghc/7.10.2/lib/ghc-7.10.2/package.conf.d
– the last component is non-js package db – possibly it should point to somewhere in ~/.ghcjs
.stack solver
does call Cabal without ghcjs flags – ghcjs-dom-hello
is a good test case: $ stack solver
This command is not guaranteed to give you a perfect build plan
It's possible that even with the changes generated below, you will still need to do some manual tweaking
Asking cabal to calculate a build plan, please wait
flags:
text:
integer-simple: false
extra-deps:
- cairo-0.13.1.0
- gio-0.13.1.0
- glib-0.13.2.1
- gtk3-0.14.0
- mtl-2.2.1
- pango-0.13.1.0
- text-1.2.1.3
- utf8-string-1
- webkitgtk3-0.14.1.0
Here it should not ask for webkitgtk3
as we're going to build with ghcjs. In https://github.com/ghcjs/ghcjs-dom/blob/master/ghcjs-dom.cabal there's condition for dependencies: if !impl(ghcjs) || flag(webkit)
which seems to be ignored by stack.
@kfigiela Thanks for trying it out! Yes, I haven't added support for ghcjsi
. I can try blindly adding that in in my next change, though. That's curious that the GHC_PACKAGE_PATH variable has a non-js DB, I'll need to look into that.
Along with fixing solver
and taking a swing at ghcjsi
support, next up is removing the use-ghcjs
flag and instead have a compiler resolver that looks like ghcjs-0.1.0_ghc-7.10.2
. A bit ugly to have both versions, but it's necessary. Is there already a way of formatting the full ghcjs version number that should be used? If there's already a consistent and not too ugly way to do that, I'd prefer to remain consistent with it.
I've pushed a new implementation which is based on a resolver setting. The resolver looks like ghcjs-0.1.0_ghc-7.10.2
. It now uses ghcjs to build the Setup.hs files, and then runs the resulting javascript in node.
This works for all stack commands except setup
, ghc
, runghc
, and ide
. It'd be easy to add support for something like ghc
, but should stack ghc
run ghcjs
? Maybe there should be a new stack ghcjs
command for that.
Since I think this is now in pretty good shape, I've opened a PR for it: https://github.com/commercialhaskell/stack/pull/802
Since #802 is merged and the only remaining item is being tracked by #749, I'd recommend closing this issue. @mgsloan any objection?
Sounds good to me!
Is there a howto/wiki to setup and get started on ghcjs using stack?
You need to be using a stack
built from master, to do that, run:
$ stack upgrade --git
Then, add
resolver: ghcjs-0.1.0.20150924_ghc-7.10.2
compiler-check: match-exact
to ~/.stack/stack.yaml
Then run
$ stack setup
(Second part copied from https://github.com/commercialhaskell/stack/issues/749#issuecomment-143248083 )
@xavier83 there is no official howto/wiki AFAIK.
For old base GHCJS you can use what @vertexcite suggested. Probably you'd want to add that resolver for a particular GHCJS project, so GHCJS won't be turned on by default.
For GHCJS master
(a.k.a. "improved base"), you can place this in your stack.yaml
(copied from https://github.com/commercialhaskell/stack/pull/1030#issuecomment-144570922):
resolver: ghcjs-0.2.0.20151001_ghc-7.10.2
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151001_ghc-7.10.2:
url: "https://github.com/fizruk/ghcjs/releases/download/v0.2.0.20151001/ghcjs-0.2.0.20151001.tar.gz"
NOTE: for the latter to work you'll currently need stack upgrade --git
(it has to do with setup-info
bug fixed in #1083).
@vertexcite @fizruk thank you both for sharing these, this is very helpful!
@fizruk could you create a wiki page for it?
@GetContented I have now created a wike page for Stack & GHCJS.
@fizruk Thank you :)
@fizruk awesome. Thanks :+1:
@fizruk Good stuff, thanks! Most of it's spot on, I've updated with some more info and a correction for the versions (stack setup
isn't supported by any released version of GHCJS).
Looking forward for it in the next release! It'll be extremely useful.
@fizruk can you take a look please?
$ cat stack.yaml
resolver: ghcjs-0.2.0.20151001_ghc-7.10.2
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151001_ghc-7.10.2:
url: "https://github.com/fizruk/ghcjs/releases/download/v0.2.0.20151001/ghcjs-0.2.0.20151001.tar.gz"
packages:
- '.'
$ stack setup
Warning: /Users/kb/workspace/ghcjs-stack-play/stack.yaml: Unrecognized field in SetupInfo: ghcjs
Warning: https://raw.githubusercontent.com/fpco/stackage-content/master/stack/stack-setup-2.yaml: Unrecognized field in SetupInfo: ghcjs
No information found for ghcjs-0.2.0.20151001_ghc-7.10.2.
Supported versions for OS key 'macosx': 7.8.4, 7.10.1, 7.10.2
$ stack --version
Version 0.1.5.0 X86_64
@k-bx: you need to stack upgrade --git
. Make sure that you have Cabal library version 1.22.4 installed (my coleague had 1.22.2 and then ghcjs-boot phase failed, maybe stack could check that?)
@k-bx you need to upgrade stack
to HEAD, see Stack & GHCJS wiki
Sorry, my bad, mis-read wiki.
I've been working to the instructions at Stack & GHCJS.
I've found a problem with hsc2hs
(whatever that is) when fails on a build of network-2.6.2.1
:
hsc2hs-ghcjs-0.2.0.20151001-7.10.2.bin: hsc2hs: rawSystem: runInteractiveProcess: exec: does not exist (No such file or directory)
hsc2hs
is present:
✔ ~/.stack/programs/x86_64-osx/ghcjs-0.2.0.20151001_ghc-7.10.2/bin
13:07 $ ~/.stack/programs/x86_64-osx/ghcjs-0.2.0.20151001_ghc-7.10.2/bin/hsc2hs-ghcjs
hsc2hs-ghcjs-0.2.0.20151001-7.10.2.bin: hsc2hs: rawSystem: runInteractiveProcess: exec: does not exist (No such file or directory)
Ok this is likely a problem with how hsc2hs
is dealt with in GHCJS. It's the only tool that isn't stand-alone, but a wrapper that calls an existing hsc2hs
provided by GHC.
Handling of these files is not quite complete yet, but something should probably change. I wonder if GHCJS should even attempt to support them, since it's really for getting information from the C compiler.
@luite said:
It's ... a wrapper that calls an existing hsc2hs provided by GHC
A ha! Adding ~/.stack/programs/x86_64-osx/ghc-7.10.2/bin/hsc2hs
to my path fixed it. Thank you.
will we be seeing any GHCJS related doc on https://www.stackage.org at some point?
@eallik @snoyberg related to Stackage, being able to list available snapshots (LTS, nightly) would be nice. If that is possible, it was impossible to find via the website.
Would a separate set of Stackage snapshots for what's "known good" w/ GHCJS be sensible?
@eallik Possibly! I don't think there's much to stackage itself related to GHCJS, though, so I imagine that this will be documented in stack / in tutorials elsewhere.
@bitemyapp If you want to read the nitty-gritty of the decision making process on that, here's the issue related to adding support for using GHCJS with stackage snapshots: https://github.com/commercialhaskell/stack/issues/1190 . So, essentially there is no need for a separate set of stackage snapshots, and ghcjs-only packages will probably get added to stackage.
@mgsloan I had assumed there wouldn't be a separate compiler field, but rather that snapshots and compilers would be bolted together with a separate submission process for GHCJS.
Much as GHCJS has done a great job with compatibility, I'm not sure it makes sense to elide the distinction in the snapshots when that distinction is made for major GHC versions.
Yes, once there's a version of GHCJS on hackage, it would be good to get it and its associated libraries into stackage. I suppose when that happens, it'll be desireable to have just plain ghcjs
be a valid value for compiler
, where the ghc and ghcjs version is provided by the snapshot.
Until then, manually specifying the compiler is the best way I can think of for this to work.
@mgsloan how about your own comment here 3 months ago? there seems to be quite a bit of information in this thread that solely applies to using stack with GHCJS? shouldn't that constitute the GHCJS specific portion of the doc?
@eallik I didn't properly understand how GHCJS worked 3 months ago. Another relevant issue is here: https://github.com/fpco/stackage-curator/issues/8 . Which doc do you think this stuff should be added to?
I'm not sure; so one can just use stack/stackage with GHCJS without having to know about how stack works with GHCJS?
@eallik It should be pretty straightforward, but the docs certainly deserved more polish. I've done that in the following commits:
Another benefit of using the same stackage snapshots for GHCJS is that you can take existing stack projects intended for GHC and build them with GHCJS via stack build --compiler ghcjs-0.1.0.20150924_ghc-7.10.2
. Once ghcjs is in stackage snapshots, it will be possible to just do stack build --compiler ghcjs
or perhaps even stack build --ghcjs
Thank you! Exactly what I meant :)
I updated @fizruk's build as of 2015-10-29
resolver: ghcjs-0.2.0.20151029_ghc-7.10.2
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151029_ghc-7.10.2:
url: "https://github.com/nrolland/ghcjs/releases/download/v0.2.0.20151029/ghcjs-0.2.0.20151029.tar.gz"
also had success setuping + building with
resolver: lts-3.0
packages:
- '.'
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151029_ghc-7.10.2:
url: "https://github.com/nrolland/ghcjs/releases/download/v0.2.0.20151029/ghcjs-0.2.0.20151029.tar.gz"
and stack setup --compiler ghcjs-0.2.0.20151029_ghc-7.10.2
stack build --compiler ghcjs-0.2.0.20151029_ghc-7.10.2
I'm not really sure if this is the right place to ask, but... I have a working setup, there's just one little hitch: stack install
works, until the copying bit: then it says Couldn't find executable cigale-web in directory [..]
. Indeed in that directory, there is no cigale-web
executable, but instead there is a cigale-web.exe
subfolder (that ideally stack
could copy recursively to my local-bin-path
).
I'll probably handle this in a custom Setup.hs
, but maybe there is a nicer solution that I'm missing here? Or is this still TODO?
@emmanueltouzery Yeah, you should just use stack build
for ghcjs. stack install
is just an alias for stack build --copy
, adding on the extra copy step. Feel free to open an issue about that. While this should work in theory, it's actually kinda nice, I'd rather not have node versions of haskell exes laying around on my PATH.
I've actually had use cases where copying the JavaScript files elsewhere would have been convenient
On Mon, Jan 25, 2016, 10:41 PM Michael Sloan notifications@github.com wrote:
@emmanueltouzery https://github.com/emmanueltouzery Yeah, you should just use stack build for ghcjs. stack install is just an alias for stack build --copy, adding on the extra copy step. Feel free to open an issue about that. While this should work in theory, it's actually kinda nice, I'd rather not have node versions of haskell exes laying around on my PATH.
— Reply to this email directly or view it on GitHub https://github.com/commercialhaskell/stack/issues/337#issuecomment-174656040 .
So finally there is first class install for ghcjs?.
I would like to install it in remote servers with scarce resources. For example in free instances of Cloud9 to enable users to clone and run example code. I can not do an installation from source there.
As a workaround, anyone know how to package and install the binaries manually? cloud9 workspaces are docker instances, so I can compile it in docker locally and translate the binaries.
So finally there is first class install for ghcjs?.
Stack has supported setting up GHCJS since v0.1.8, back in November of 2015
I would like to install it in remote servers with scarce resources. For example in free instances of Cloud9 to enable users to clone and run example code. I can not do an installation from source there.
Perhaps use docker? You may need to figure out how to do a binary distribution of GHCJS, afaik no one has figured out how to do a binary distribution, other than mechanisms like docker.
@mgsloan Maybe we can get stack to use nix's binary package distribution infrastructure somehow?
@ryantrinkle Perhaps so! Yes, nix is also a great approach, as demonstrated by your repo https://github.com/reflex-frp/reflex-platform
Looks like runInteractiveProcess
issue is still appears (I got it on my Travis GHCJS build via stack
using LTS 7.7 with according compiler snapshot from Marcin).
Sample error message:
hsc2hs: rawSystem: runInteractiveProcess: exec: does not exist (No such file or directory)
To resolve this I added stack --no-terminal --install-ghc install hsc2hs
in build section for GHCJS case (see this commit).
hsc2hs: rawSystem: runInteractiveProcess: exec: does not exist (No such file or directory)
i resolve this by :
vim ~/.bash_profile
export PATH=$PATH:/Users/yourMacUserName/.stack/programs/x86_64-osx/ghc-8.0.1/bin:/Users/hack/.local/bin
because hsc2hs is in /Users/yourMacUserName/.stack/programs/x86_64-osx/ghc-8.0.1/bin
Are there plans to support GHCJS in the same first class way as GHC (i.e. getting the binaries etc.)?