commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

Cannot install GHCJS while in Nix-shell mode #1882

Closed Rizary closed 8 years ago

Rizary commented 8 years ago

Hi, I have the following stack.yaml:

# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration.html

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-5.5

# Local packages, usually specified by relative directory name
packages:
- '.'

# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps:
- ghcjs-dom-0.2.3.1
- ref-tf-0.4
- webkitgtk3-0.14.1.1
- webkitgtk3-javascriptcore-0.13.1.1
- haskell-src-exts-1.16.0.1
- syb-0.5.1
- aeson-0.9.0.1

# Override default flag values for local packages and extra-deps
flags: {}

# Extra package databases containing global packages
extra-package-dbs: []

# Control whether we use the GHC we find on the path
# system-ghc: true

# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: >= 1.0.0

# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64

# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]

# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor

# add GHCJS configuration
compiler: ghcjs-0.2.0.20151230.3_ghc-7.10.2
compiler-check: match-exact
setup-info:
 ghcjs:
  source:
   ghcjs-0.2.0.20151230.3_ghc-7.10.2:
    url: "https://github.com/nrolland/ghcjs/releases/download/v.0.2.0.20151230.3/ghcjs-0.2.0.20151230.3.tar.gz"

#nix-configuration
nix:
 enable: true
 shell-file: ../../haskell-nix/shell.nix

and when i do

stack setup

inside nix-shell mode, i got the following error:

Preparing to install GHCJS to an isolated location.
This will not interfere with any system-level installation.
No sha1 found in metadata, download hash won't be checked. 
Already downloaded.                                        
Unpacking GHCJS into /home/user/.stack/programs/x86_64-linux/ghcjs-0.2.0.20151230.3_ghc-7.10.2/src/ ...Expected a single directory within unpacked /home/user/.stack/programs/x86_64-linux/ghcjs-0.2.0.20151230.3_ghc-7.10.2.tar.gz

I have install stack inside the nix-shell, and when i do stack install (e.g. reflex-dom),:

stack install reflex-dom

i got the following error:

No compiler found, expected exact version ghcjs-0.2.0.20151230.3_ghc-7.10.2 (x86_64) (based on resolver setting in /home/user/folrdertest/testinstall/stack.yaml).
Try running "stack setup" to install the correct GHC into /home/user/.stack/programs/x86_64-linux/

when doing stack setup, the same error above happened.

Any idea where i am doing wrong??

mgsloan commented 8 years ago

Looks a lot like a bug I fixed 3 days ago https://github.com/commercialhaskell/stack/issues/1874

Please try with the latest HEAD of stack (either via the repo or via stack upgrade --git

Rizary commented 8 years ago

Hi, thank you.

I have done

stack upgrade --git

but got this error:

Information about the commit this version of stack was built from is not available due to how it was built. Will continue by assuming an upgrade is needed because we have no information to the contrary.
Cloning stack
Cloning into 'stack'...
remote: Counting objects: 399, done.
remote: Compressing objects: 100% (294/294), done.
remote: Total 399 (delta 43), reused 238 (delta 30), pack-reused 0
Receiving objects: 100% (399/399), 496.57 KiB | 145.00 KiB/s, done.
Resolving deltas: 100% (43/43), done.
Checking connectivity... done.
path-io-1.0.0: configure
path-io-1.0.0: build
hpack-0.10.0: configure
hpack-0.10.0: build
path-io-1.0.0: copy/register
hpack-0.10.0: copy/register
stack-1.0.5: configure
Configuring stack-1.0.5...
stack-1.0.5: build
Preprocessing library stack-1.0.5...
[ 1 of 86] Compiling Stack.FileWatch  ( src/Stack/FileWatch.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Stack/FileWatch.o )
[ 2 of 86] Compiling System.Process.PagerEditor ( src/System/Process/PagerEditor.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/System/Process/PagerEditor.o )
[ 3 of 86] Compiling Stack.Types.Config[boot] ( src/Stack/Types/Config.hs-boot, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Stack/Types/Config.o-boot )
[ 4 of 86] Compiling System.Process.Log ( src/System/Process/Log.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/System/Process/Log.o )
[ 5 of 86] Compiling System.Process.Read ( src/System/Process/Read.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/System/Process/Read.o )
<command line>: can't load .so/.DLL for: libz.so (libz.so: cannot open shared object file: No such file or directory)
Completed 3 action(s).

--  While building package stack-1.0.5 using:
      /home/R/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:stack exe:stack --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

i have add this to my stack.yaml project:

extra-include-dirs:
- /nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/include
extra-lib-dirs:
/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/lib

but still got the same error. (i am doing this inside nix-shell

Rizary commented 8 years ago

SOrry for long issues, the way i solved this is by adding pkgs.zlib in my default.nix

and it worked.

Thanks @mgsloan for stack upgrade --git

Rizary commented 8 years ago

Ok, now i am stuck a little bit more.. after i do stack upgrade --git the stack bin goes to my /home/user/.local/bin whereas it should be in my /home/user/.nix-profile/bin/stack which symlink into my nix/store.

should i include it in my PATH? which sound a non-nixos way..

i have already try to install haskellPackages.stack_0_1_0_4_1, but too many dependencies missing and I cannot find it in my nixpkgs.

up until now, when i do stack setup it will fails as in my error:

--  While building package stack-1.0.5 using:
      /home/R/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:stack exe:stack --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

again... I already tried to fetchgit the stack in my default.nix but it does not install stack.

so i need to open again this issue.

thanks, Rizy

Rizary commented 8 years ago

Update:

I have uninstall stack by nix-env -e stack

and try to add my upgraded stack bin in ~/.local/bin/stack to my PATH.

stack is work, but when i do stack setup i got the following error

these paths will be fetched (0.26 MiB download, 1.65 MiB unpacked):
  /nix/store/1ac7xn6c69xh3jxd360xs2bn8848mnm4-stdenv
  /nix/store/phffkvah78v10kjmfmllmla1wq9qa4xr-bash-4.3-p42-doc
fetching path ‘/nix/store/phffkvah78v10kjmfmllmla1wq9qa4xr-bash-4.3-p42-doc’...
fetching path ‘/nix/store/1ac7xn6c69xh3jxd360xs2bn8848mnm4-stdenv’...

*** Downloading ‘https://cache.nixos.org/nar/024pc2ir4xg0kd2ikv1wpwyzz14bfp4cqr30qfdlzq89zs9c5vjb.nar.xz’ (signed by ‘cache.nixos.org-1’) to ‘/nix/store/phffkvah78v10kjmfmllmla1wq9qa4xr-bash-4.3-p42-doc’...

*** Downloading ‘https://cache.nixos.org/nar/0dxgg76019cz8kh4r6dv6d7jk18svfvz4457bw9b2haxxgb0f00m.nar.xz’ (signed by ‘cache.nixos.org-1’) to ‘/nix/store/1ac7xn6c69xh3jxd360xs2bn8848mnm4-stdenv’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7400  100  7400    0     0   4858      0  0:00:01  0:00:01 --:--:--  4855

100  255k  100  255k    0     0  94531      0  0:00:02  0:00:02 --:--:-- 94513

Preparing to install GHCJS to an isolated location.
This will not interfere with any system-level installation.
No sha1 found in metadata, download hash won't be checked. 
Already downloaded.                                        
Unpacking GHCJS into /home/user/.stack/programs/x86_64-linux-nix/ghcjs-0.2.0.20151230.3_ghc-7.10.2/src/ .                                                                                                      Setting up GHCJS build environmentPreparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.                 
Running /run/user/1001/stack-setup6722/ghc-7.10.2/configure --prefix=/home/user/.stack/programs/x86_64-linux-nix/ghc-7.10.2/ in directory /run/user/1001/stack-setup6722/ghc-7.10.2/ exited with ExitFailure 1

checking for path to top of build tree... 
/run/user/1001/stack-setup6722/ghc-7.10.2/configure: utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist: /bin/bash: bad interpreter: No such file or directory
configure: error: cannot determine current directory

Configuring GHC ...

ok for now, i think i will leave stack alone if want use GHCJS and use other way instead. it is very daunting to keep going on with this.

Rizy

mgsloan commented 8 years ago

@Rizary Probably the reason you are running into issues is that GHCJS support and nix support are both rather special features, which probably haven't been mixed often. Here's some great purely nix stuff for using reflex: https://github.com/reflex-frp/reflex-platform

I'm not very familiar with nix, but it seems to me like you don't have a working version of bash in your environment.

@YPares Are people intended to use stack setup with the nix support? Does it make any sense to change the default local-bin-path for the nix case?

YPares commented 8 years ago

@mgsloan stack --nix setup should be a noop if GHC is already present in the nix store. If it isn't, then the nix-shell started by any stack --nix command should download it first, so people are not required to launch stack --nix setup. As for the path, we rely on the one set by the nix-shell, and just call stack by absolute pack when restarting stack in the nix-shell, so normally local-bin-path doesn't have to be changed Indeed we haven't thought about using nix support with anything else than GHC, but @Rizary can you try using the ghcjs from nixpkgs (haskell.compiler.ghcjs) instead of downloading it from https://github.com/nrolland/ghcjs/releases/download/v.0.2.0.20151230.3/ghcjs-0.2.0.20151230.3.tar.gz?

Rizary commented 8 years ago

Hi,

i got the following results after using haskell.compiler.ghcjs


The GHC located at /nix/store/iii9kqiacqcn3xd05mlamv5f6dfy6y3b-ghcjs-0.2.0/bin/ghcjs failed to compile a sanity check. Please see:

    http://docs.haskellstack.org/en/stable/install_and_upgrade/

for more information. Exception was:
Running /nix/store/iii9kqiacqcn3xd05mlamv5f6dfy6y3b-ghcjs-0.2.0/bin/ghcjs /run/user/1001/stack-sanity-check28364/Main.hs -no-user-package-db in directory /run/user/1001/stack-sanity-check28364/ exited with ExitFailure 1
mgsloan commented 8 years ago

Seems like ghcjs isn't working, and isn't outputting anything. What does stack exec -- ghcjs --version do? stack exec -- ghcjs Test.hs?

Rizary commented 8 years ago

Ok i have done several things...

first, when i excute stack exec -- ghcjs --version it gets an error

No compiler found, expected minor version match or newer with ghcjs-0.2.0.20151230.3_ghc-7.10.2 (x86_64) (based on resolver setting in /home/R/AllHaskell/reflex-impress/stack.yaml).
Try running "stack setup" to install the correct GHC into /home/R/.stack/programs/x86_64-linux-nix/

then i do stack setup and gets the following error:

No information found for ghcjs-0.2.0_ghc-7.10.3.
Supported versions for OS key 'source': GhcjsVersion 0.1.0.20150924 7.10.2

since lts-5.5 attribute always missing, i changed it into lts-5.2, but the above error still happened.

Then i remove the shell-file parts, and added my stack.yaml with packages: [ pkgs.haskell.compiler.ghcjs ], and do stack setup, but then this error happened:

Warning: No remote package servers have been specified. Usually you would have
one specified in the config file.
Resolving dependencies...
Failed to install Cabal-1.22.4.0
cabal: Error: some packages failed to install:
Cabal-1.22.4.0 failed during the configure step. The exception was:
user error (The package 'Cabal' requires Cabal library version -any && >=1.10
but no suitable version is installed.)
ghcjs-boot: error running: /nix/store/p469cjd3fd30yb3bkj9yfxmg4sjkd6w3-cabal-install-1.22.8.0/bin/cabal --config-file /nix/store/lp8mzbcbn0yj533x2yrkkzsgkr6505ik-ghcjs-0.2.0/lib/ghcjs-0.2.0/cabalBootConfig --ignore-sandbox install ./boot/cabal/Cabal --global --ghcjs --one-shot --avoid-reinstalls --builddir dist --with-compiler /nix/store/lp8mzbcbn0yj533x2yrkkzsgkr6505ik-ghcjs-0.2.0/bin/ghcjs --with-gcc /nix/store/f1p2lhaa5aj3g4ca9clvp43wyy7ymm6m-gcc-wrapper-4.9.3/bin/cc --with-hc-pkg /nix/store/lp8mzbcbn0yj533x2yrkkzsgkr6505ik-ghcjs-0.2.0/bin/ghcjs-pkg --prefix /nix/store/lp8mzbcbn0yj533x2yrkkzsgkr6505ik-ghcjs-0.2.0 --libdir $prefix/lib/$compiler --libsubdir $pkgid --enable-documentation --haddock-html --haddock-hoogle --haddock-hyperlink-source --enable-shared --enable-library-profiling --root-cmd /nix/store/lp8mzbcbn0yj533x2yrkkzsgkr6505ik-ghcjs-0.2.0/lib/ghcjs-0.2.0/run.sh
exit status: 1
stderr: Warning: No remote package servers have been specified. Usually you would have
one specified in the config file.
cabal: Error: some packages failed to install:
Cabal-1.22.4.0 failed during the configure step. The exception was:
user error (The package 'Cabal' requires Cabal library version -any && >=1.10
but no suitable version is installed.)

builder for ‘/nix/store/f5chbm2cnkvvxbq4115n95pk4fng4syy-ghcjs-0.2.0.drv’ failed with exit code 1
error: build of ‘/nix/store/f5chbm2cnkvvxbq4115n95pk4fng4syy-ghcjs-0.2.0.drv’ failed
/run/current-system/sw/bin/nix-shell: failed to build all dependencies
mgsloan commented 8 years ago

Since ghcjs old base isn't changing anymore, we have an image for ghcjs-0.1. There has not been an official release of 0.2, so we don't have a tarball url for it. See the docs here http://docs.haskellstack.org/en/stable/ghcjs/

mgsloan commented 8 years ago

BTW I have no idea what will happen if you try to use stack setup for ghcjs while also having ghcjs in the nix sandbox. It should install another ghcjs and use it instead of the nix ghcjs, but not 100% sure, particularly if the version numbers of the two ghcjs installs are the same, could get funky behavior where two different versions are using the same DBs.

Rizary commented 8 years ago

yeah true.. but still got the same error after doing that..:)

mgsloan commented 8 years ago

Remove compiler-check: match-exact. The issue is that lts-5 uses GHC-7.10.3, but I guess those GHCJS versions are build against 7.10.2

I'm not sure about the issue with cabal. Maybe try stack install cabal-install --resolver lts-5.5, with the global project (outside of the dir with stack.yaml)?

mgsloan commented 8 years ago

Closing this, as it's an old support ticket. If you think this is in error, please comment with more info.