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

Custom setup breaks with ghcjs #4742

Closed
nomeata opened this issue Sep 4, 2017 · 21 comments
Closed

Custom setup breaks with ghcjs #4742

nomeata opened this issue Sep 4, 2017 · 21 comments

Comments

@nomeata
Copy link
Contributor

nomeata commented Sep 4, 2017

While having a recent ghcjs based on GHC-8.0 in my $PATH I tried to build a package that depends on gc (as an example for a package with a custom setup file) with the following cabal file:

name:                foo
version:             0.1.0.0
license:             BSD3
license-file:        LICENSE
author:              Joachim Breitner
maintainer:          mail@joachim-breitner.de
build-type:          Simple
extra-source-files:  ChangeLog.md
cabal-version:       >=1.10

library
  build-depends:       base >=4.9 && <4.10, gc
  default-language:    Haskell2010

and I got this:

/tmp/foo $ cabal new-build --ghcjs
Warning: don't know how to find change monitoring files for the installed
package databases for ghcjs
Resolving dependencies...
Warning: don't know how to find change monitoring files for the installed
package databases for ghcjs
In order, the following will be built (use -v for more details):
cabal-doctest-1.0.2
gc-0.0.2
foo-0.1.0.0
Configuring cabal-doctest-1.0.2...
Building cabal-doctest-1.0.2...
Preprocessing library cabal-doctest-1.0.2...
[1 of 1] Compiling Distribution.Extra.Doctest ( src/Distribution/Extra/Doctest.hs, dist/build/Distribution/Extra/Doctest.js_o )
Installing library in
/home/jojo/.cabal/store/ghcjs-0.2.1/cabal-doctest-1.0.2-b6c060cc4355571b3c7bde4854f8b4df7631e45f3e680c034a5d1e374280b376/lib
Creating package registration file:
/tmp/foo/dist-newstyle/tmp/package-registration-11015139291801979802
[1 of 1] Compiling Main             ( /tmp/foo/dist-newstyle/tmp/gc-17531/gc-0.0.2/dist/setup/setup.hs, /tmp/foo/dist-newstyle/tmp/gc-17531/gc-0.0.2/dist/setup/Main.js_o )
Linking /tmp/foo/dist-newstyle/tmp/gc-17531/gc-0.0.2/dist/setup/setup.jsexe (Main)
Configuring gc-0.0.2...
setup: The program 'ghcjs' version >=0.1 is required but the version of
/home/jojo/.bin/ghcjs could not be determined.

This happens both with cabal being 1.24 and today’s HEAD (2.1).

What can I do about this (without patching gc or so)?

@nomeata
Copy link
Contributor Author

nomeata commented Sep 4, 2017

I think in both cases the ghcjs-provided Cabal-1.24 is used to build the custom setup program.

@nomeata
Copy link
Contributor Author

nomeata commented Sep 4, 2017

I tried to force it to use a newer Cabal to build the custom setup program, but it seems that --constraint Cabal >=2.0 is being ignored when it comes to determining the dependencies for setup files. Is there a way I can make cabal use a newer Cabal when building gc’s setup?

(But it would not help anyways, if I patch gc to use Cabal-2.0, I still get this error.)

@nomeata
Copy link
Contributor Author

nomeata commented Sep 4, 2017

The problem is not specific to new-build, the problem can be observed simply with

$ cabal-2.1 install gc --ghcjs
Resolving dependencies...
[1 of 1] Compiling Main             ( /tmp/cabal-tmp-21904/gc-0.0.2/dist/setup/setup.hs, /tmp/cabal-tmp-21904/gc-0.0.2/dist/setup/Main.js_o )
Linking /tmp/cabal-tmp-21904/gc-0.0.2/dist/setup/setup.jsexe (Main)
Configuring gc-0.0.2...
setup: The program 'ghcjs' version >=0.1 is required but the version of
/home/jojo/.bin/ghcjs could not be determined.
Failed to install gc-0.0.2
cabal-2.1: Error: some packages failed to install:
gc-0.0.2-AiSszylvpSAHDmEyMbsnAn failed during the configure step. The
exception was:
ExitFailure 1

@23Skidoo
Copy link
Member

23Skidoo commented Sep 4, 2017

Is there a way I can make cabal use a newer Cabal when building gc’s setup?

Try using --constraint=setup.Cabal >=2 or --constraint=gc:setup.Cabal >=2. See here for more info about setup constraints.

@nomeata
Copy link
Contributor Author

nomeata commented Sep 4, 2017

Not specific to cabal-install at all, purely a Cabal/ghcjs problem:

/tmp/gc-0.0.2 $ ghcjs --make Setup.lhs 
Linking Setup.jsexe (Main)
/tmp/gc-0.0.2 $ node Setup.jsexe/all.js configure --ghcjs
Configuring gc-0.0.2...
all.js: The program 'ghcjs' version >=0.1 is required but the version of
/home/jojo/.bin/ghcjs could not be determined.

@nomeata
Copy link
Contributor Author

nomeata commented Sep 4, 2017

I might be hitting the problem described in commercialhaskell/stack#1496

@23Skidoo
Copy link
Member

23Skidoo commented Sep 5, 2017

@nomeata Does compiling the setup script with 2.0 help?

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

Nope. same problem, reproduced with:

$ cabal install --ghcjs Cabal-2.0.0.2
$ ghcjs --make Setup.lhs -v
-- checking that indeed `Cabal-2.0.0.2` is used
$ node Setup.jsexe/all.js configure --ghcjs 

@23Skidoo
Copy link
Member

23Skidoo commented Sep 5, 2017

What is the output of /home/jojo/.bin/ghcjs --version?

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

$ /home/jojo/.bin/ghcjs --version
The Glorious Glasgow Haskell Compilation System for JavaScript, version 0.2.1 (GHC 8.0.2)

@23Skidoo
Copy link
Member

23Skidoo commented Sep 5, 2017

Does /home/jojo/.bin/ghcjs --numeric-ghcjs-version work? That's the method used by Cabal to determine GHCJS version.

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

$ /home/jojo/.bin/ghcjs --numeric-ghcjs-version
0.2.1

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

According to strace -e read,write,execve -f node Setup.jsexe/all.js configure --ghcjs -v3, ghcjs --numeric-ghcjs-version is not even called. I wonder if there is something severely wrong with GHCJS/node.

@23Skidoo
Copy link
Member

23Skidoo commented Sep 5, 2017

/cc @luite

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

Ah, I see something. With -v3 I get

Warning: cannot determine version of /home/jojo/.bin/ghcjs :
"Linking a.jsexe ()\n"

So somehow instead of the version number the Setup code is trying to parse this string. But where does it come from?

@23Skidoo
Copy link
Member

23Skidoo commented Sep 5, 2017

-v3 should tell you what programs Cabal invoked.

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

Full output:

/tmp/gc-0.0.2 $ node Setup.jsexe/all.js configure --ghcjs -v3
Configuring gc-0.0.2...
creating dist/build
Searching for ghcjs in path.
Found ghcjs at /home/jojo/.bin/ghcjs
/home/jojo/.bin/ghcjs --numeric-ghcjs-version
Warning: cannot determine version of /home/jojo/.bin/ghcjs :
"Linking a.jsexe ()\n"
CallStack (from HasCallStack):
  die', called at ./Distribution/Simple/Program/Db.hs:484:18 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple.Program.Db
  requireProgramVersion, called at ./Distribution/Simple/GHCJS.hs:61:5 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple.GHCJS
  configure, called at ./Distribution/Simple/Configure.hs:1592:14 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple.Configure
  configCompilerEx, called at ./Distribution/Simple/Configure.hs:395:12 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple.Configure
  configure, called at ./Distribution/Simple.hs:570:20 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple
  confHook, called at ./Distribution/Simple/UserHooks.hs:67:5 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple.UserHooks
  configureAction, called at ./Distribution/Simple.hs:174:19 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple
  defaultMainHelper, called at ./Distribution/Simple.hs:119:27 in Cabal-2.0.0.2-FM1cexNFvRMK0jH27C02s:Distribution.Simple
  defaultMain, called at Setup.lhs:30:8 in main:Main
all.js: The program 'ghcjs' version >=0.1 is required but the version of
/home/jojo/.bin/ghcjs could not be determined.

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

Fun fact:

$ /home/jojo/.bin/ghcjs ""
Linking a.jsexe ()

and indeed, it seems that ghcjs is called with an empty string as an argument

[pid 16650] execve("/home/jojo/.bin/ghcjs", ["/home/jojo/.bin/ghcjs", ""], [/* 55 vars */] <unfinished ...>

@23Skidoo
Copy link
Member

23Skidoo commented Sep 5, 2017

Looks like the same happens when /home/jojo/.bin/ghcjs --numeric-ghcjs-version is invoked programmatically by Cabal.

@nomeata
Copy link
Contributor Author

nomeata commented Sep 5, 2017

Ok, it is definitely a problem with ghcjs and/or node:

/tmp $ cat Test.hs 
import System.Process
main = rawSystem "ghcjs" ["--numeric-ghcjs-version"]
/tmp $ ghcjs -O Test.hs 
[1 of 1] Compiling Main             ( Test.hs, Test.js_o )
Linking Test.jsexe (Main)
/tmp $ node Test.jsexe/all.js
Linking a.jsexe ()

@23Skidoo
Copy link
Member

23Skidoo commented Sep 5, 2017

I guess that this ticket can be closed then since this is not a bug in Cabal?

@nomeata nomeata closed this as completed Sep 5, 2017
luigy added a commit to reflex-frp/reflex-platform that referenced this issue Oct 14, 2017
* ghcjs/shims@85395dc
fixes Cabal build.  This seems related to haskell/cabal#4742
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants