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

1.9.1 fails to build from tarball without .git/ #4364

Closed
juhp opened this issue Oct 19, 2018 · 19 comments
Closed

1.9.1 fails to build from tarball without .git/ #4364

juhp opened this issue Oct 19, 2018 · 19 comments
Labels

Comments

@juhp
Copy link
Contributor

juhp commented Oct 19, 2018

General summary/comments (optional)

Getting compilation errors in Main.hs see below for details

Steps to reproduce

Build 1.9.1 in a cabal sandbox.

Buildlog: https://copr-be.cloud.fedoraproject.org/results/petersen/stack/fedora-rawhide-x86_64/00812150-stack/build.log.gz

(See https://copr-dist-git.fedorainfracloud.org/cgit/petersen/stack/stack.git/tree/stack.spec?id=d786c497ff6c79c885688e8bd7976d31eaf849fa#n139 for exact build steps.)

Expected

Successful build

Actual

Fail failed:

[3 of 3] Compiling Main             ( src/main/Main.hs, dist/dist-sandbox-ccff8d/build/stack/stack-tmp/Main.o )
src/main/Main.hs:131:16: error:
    * Ambiguous type variable `a0' arising from a use of `show'
      prevents the constraint `(Show a0)' from being solved.
      Probable fix: use a type annotation to specify what `a0' should be.
      These potential instances exist:
        instance [safe] Show (Doc a)
          -- Defined in `Text.PrettyPrint.Annotated.Leijen'
        instance Show a => Show (ZipList a)
          -- Defined in `Control.Applicative'
        instance (Show b, Show a) => Show (Either a b)
          -- Defined in `Data.Either'
        ...plus 124 others
        ...plus 282 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    * In the first argument of `(++)', namely `show commitCount'
      In the second argument of `(++)', namely
        `show commitCount ++ " commits)"'
      In the expression: " (" ++ show commitCount ++ " commits)"
    |
131 |     , [" (" ++ show commitCount ++ " commits)" | commitCount /= 1]
    |                ^^^^^^^^^^^^^^^^
src/main/Main.hs:136:33: error:
    * Exception when trying to run compile-time code:
        git: readCreateProcessWithExitCode: runInteractiveProcess: exec: does not exist (No such file or directory)
      Code: tGitInfoCwd
    * In the Template Haskell splice $$tGitInfoCwd
      In the first argument of `giCommitCount', namely `$$tGitInfoCwd'
      In the expression: giCommitCount $$tGitInfoCwd
    |
136 |     commitCount = giCommitCount $$tGitInfoCwd
    |                                 ^^^^^^^^^^^^^
cabal: Leaving directory '.'

Method of installation

  • Via cabal-install
@juhp
Copy link
Contributor Author

juhp commented Oct 19, 2018

Same result with ghc-8.4.3
https://copr.fedorainfracloud.org/coprs/petersen/stack/build/812179/

FWIW I am building with the revised .cabal file from Hackage.

@qrilka
Copy link
Contributor

qrilka commented Oct 19, 2018

As far as I understand you need to use flag disable-git-info as you won't have .git when installing with cabal-install. And the same thing existed in the previous version 1.7.1 too

@juhp
Copy link
Contributor Author

juhp commented Oct 19, 2018

@qrilka I see, but I didn't have a problem 1.7.1.

@juhp
Copy link
Contributor Author

juhp commented Oct 19, 2018

But thanks that fixed 1.9.1 for me.

@borsboom
Copy link
Contributor

borsboom commented Oct 19, 2018

stack-1.7.1 built with gitrev which I think handled a missing .git gracefully. stack-1.9.1 builds with https://github.com/snoyberg/githash which, based on the type signatures, doesn't seem to work if there's a missing .git directory.

I don't think we should default the disable-git-info flag to true, although that would be one way around. In most cases, having the git info there by default is desirable. I think I'd rather that githash could handle this gracefully and that stack --version just indicates git info isn't available when it's built outside of a git repo.

@snoyberg I see githash is your package, does this sound reasonable?

@borsboom
Copy link
Contributor

This is probably the same thing as #4363.

@juhp juhp changed the title 1.9.1 failed to build with ghc-8.2.2 1.9.1 fails to build from tarball without .git/ Oct 20, 2018
@snoyberg
Copy link
Contributor

I'm not sure if gitrev handled this "gracefully," I think it simply provided incorrect information. The question is: what should we ideally do in a case where the flags are saying "use Git information" and there isn't any Git information? Options:

  1. What we do now: error out
  2. Fill in dummy information (I think it was blank strings previously)
  3. Fill in an explicit message saying we didn't have the Git info available

It seems to me that (3) is the best choice. I'll make the necessary changes to githash for that.

snoyberg added a commit that referenced this issue Oct 21, 2018
@snoyberg
Copy link
Contributor

I've created a commit to address this (85a2b97). I'm not sure which branch to send the PR to though.

@borsboom
Copy link
Contributor

Yeah, you're right gitrev wasn't exactly graceful, I think it returned a string containing "unknown" which isn't great. I agree (3) is the right choice. I think the stable branch would be good so that any minor release includes the change, and then merge stable in the master so it's there too.

@juhp
Copy link
Contributor Author

juhp commented Nov 19, 2018

With 1.9.1.1 I get:

src/main/Main.hs:131:30: error:
    * Exception when trying to run compile-time code:
        git: readCreateProcessWithExitCode: runInteractiveProcess: exec: does not exist (No such file or directory)
      Code: tGitInfoCwdTry
    * In the Template Haskell splice $$tGitInfoCwdTry
      In the second argument of `(<$>)', namely `$$tGitInfoCwdTry'
      In the expression: giCommitCount <$> $$tGitInfoCwdTry
    |
131 |     , case giCommitCount <$> $$tGitInfoCwdTry of
    |                              ^^^^^^^^^^^^^^^^

https://copr.fedorainfracloud.org/coprs/petersen/stack/build/826407/ (this using ghc-8.2.2)

@dbaynard
Copy link
Contributor

@juhp Thanks for the report. How can I view the build log at copr?

@juhp
Copy link
Contributor Author

juhp commented Nov 20, 2018

You click on fedora-rawhide-x86_64 (okay I should probably link directly there next time).

@dbaynard
Copy link
Contributor

Ah, it was builder-live.log — it wasn't obvious which file to check.

The issue is in githash — it looks like the compiler is failing to find git. Is git present on your build (it looks like it is, at some point)? Otherwise is cabal-install providing an environment without git on the path?

The fix is either for githash to fail gracefully when there is no git on the path (at least improving the error message needs), or for stack to catch the exception.

@snoyberg I'll raise the issue on githash — what would you prefer, here?

@snoyberg
Copy link
Contributor

This should already be addressed by #4368. @borsboom did you mention that this was release to Hackage as 1.9.1.1?

@dbaynard
Copy link
Contributor

Yes, this is with 1.9.1.1

@dbaynard
Copy link
Contributor

stack/src/main/Main.hs

Lines 125 to 138 in a953002

versionString' :: String
#ifdef USE_GIT_INFO
versionString' = concat $ concat
[ [$(simpleVersion Meta.version)]
-- Leave out number of commits for --depth=1 clone
-- See https://github.com/commercialhaskell/stack/issues/792
, case giCommitCount <$> $$tGitInfoCwdTry of
Left _ -> []
Right 1 -> []
Right count -> [" (", show count, " commits)"]
, [" ", Cabal.display buildArch]
, [depsString, warningString]
]
#else

So if runGit in githash throws an exception, the tGitInfoCwdTry splice won't compile?

@snoyberg
Copy link
Contributor

Thanks for the clarification @dbaynard, I read through this too quickly.

@juhp would it be possible to test a commit of githash from Github, or would you need a Hackage release? I believe snoyberg/githash@48f0c95 will fix this.

@snoyberg
Copy link
Contributor

@juhp I've made the release to Hackage.

@juhp
Copy link
Contributor Author

juhp commented Nov 25, 2018

@juhp juhp closed this as completed Nov 25, 2018
juhp added a commit to fedora-haskell/stack that referenced this issue Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants