Bug 246800

Summary: lang/ghc: ghc cannot be installed because ghc is not installed
Product: Ports & Packages Reporter: Bertram Scharpf <software>
Component: Individual Port(s)Assignee: freebsd-haskell (Nobody) <haskell>
Status: Closed FIXED    
Severity: Affects Many People CC: arrowd
Priority: --- Flags: bugzilla: maintainer-feedback? (haskell)
Version: Latest   
Hardware: Any   
OS: Any   

Description Bertram Scharpf 2020-05-28 08:14:01 UTC
This is what happens:

  root@packager /usr/ports/lang/ghc # make
  [...]
  ===>  Configuring for ghc-8.8.3_1
  cp -f /usr/ports/lang/ghc/work/build.mk /usr/ports/lang/ghc/work/ghc-8.8.3/mk/build.mk
  configure: loading site script /usr/ports/Templates/config.site
  [...]
  checking for ghc... /usr/local/bin/ghc
  checking version of ghc... unknown
  configure: error: Cannot determine the version of /usr/local/bin/ghc.  Is it really GHC?
  ===>  Script "configure" failed unexpectedly.
  [...]
  *** Error code 1
  
  Stop.
  make: stopped in /usr/ports/lang/ghc

I detected that GHC=/usr/local/bin/ghc is added to the ./configure
arguments list. Then I gave up.

I removed the port and package because a previous build failed and
I wanted to finish all other updates before solving this problem.
Comment 1 Gleb Popov freebsd_committer freebsd_triage 2020-05-28 08:33:27 UTC
Please, show output of

# make showconfig
Comment 2 Bertram Scharpf 2020-05-28 09:17:28 UTC
Aarrrgh! It says:

  ====> Bootsrap using installed ghc
       BOOT=on: Use installed GHC for bootstrapping

In this case, the bug is that the option does not read
"Use installed GHC _if_ _installed_." Or at least a message
should be shown that the option was turned on.

The build is currently running and I'm optimistic. Thanks so far.
Comment 3 Gleb Popov freebsd_committer freebsd_triage 2020-05-28 09:24:21 UTC
Well, I find it obvious that you can't install GHC while you are building it.
Comment 4 Bertram Scharpf 2020-05-28 11:05:06 UTC
Then, why does the port try to do that and afterwards wants to make me believe it was my mistake?
Comment 5 Gleb Popov freebsd_committer freebsd_triage 2020-05-28 11:54:08 UTC
The port tries to use installed GHC, just as option's description says. It fails, because you did not provide GHC. It doesn't say that it will try to obtain GHC for you in some magic way.
Comment 6 Bertram Scharpf 2020-05-28 12:13:39 UTC
> The port tries to use installed GHC, just as option's description says. It
> fails, because you did not provide GHC. It doesn't say that it will try to
> obtain GHC for you in some magic way.

The port detects that ghc is not installed. It would be no more than one line
of code to inform the user that this clashes with the option that was selected.
There is no need to obtain it in this situation.

I cannot remember all 2k options I selected in any port since I first installed
FreeBSD. We have machines to do the things that we're not capable of, and we
have machines to do the things that are obvious and that are repetitive.

This behaviour is definitely a bug.
Comment 7 Gleb Popov freebsd_committer freebsd_triage 2020-05-28 12:37:55 UTC
Makes sense. Would following change be helpful?

Index: lang/ghc/Makefile
===================================================================
--- lang/ghc/Makefile   (revision 536651)
+++ lang/ghc/Makefile   (working copy)
@@ -254,6 +254,11 @@
 .if empty(PORT_OPTIONS:MBOOT)
        cd ${BOOT_DIR} && ${CONFIGURE_ENV} ${CONFIGURE_CMD} --prefix=${BOOT_DIR}
        cd ${BOOT_DIR} && PACKAGES='' ${MAKE_CMD} install
+.else
+# otherwise, make sure we have "ghc" in PATH
+       if ! ${WHICH} -s ghc ; then \
+               echo "No 'ghc' executable is found in your PATH! Turn off BOOT option." ; false ; \
+       fi
 .endif
 # If DOCS are set, install HsColour in-place
 .if ${PORT_OPTIONS:MDOCS}
Comment 8 Bertram Scharpf 2020-05-28 12:57:27 UTC
Works fine. Thanks!
Comment 9 commit-hook freebsd_committer freebsd_triage 2020-05-28 12:59:25 UTC
A commit references this bug:

Author: arrowd
Date: Thu May 28 12:58:56 UTC 2020
New revision: 536766
URL: https://svnweb.freebsd.org/changeset/ports/536766

Log:
  lang/ghc: Print a error message if BOOT option is enabled, but the user has no "ghc" in PATH.

  PR:		246800
  Submitted by:	software@bertram-scharpf.de

Changes:
  head/lang/ghc/Makefile
Comment 10 Gleb Popov freebsd_committer freebsd_triage 2020-05-28 13:00:04 UTC
Thanks for bringing this up.