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

Can't run fancyassertions #1453

Closed
DamienCassou opened this issue Jan 11, 2021 · 2 comments
Closed

Can't run fancyassertions #1453

DamienCassou opened this issue Jan 11, 2021 · 2 comments
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. docs Documentation-related. tools hledger developer tools, scripts, processes..

Comments

@DamienCassou
Copy link
Contributor

I have just updated hledger repository to latest master (which is b203822) and ran stack install. I can't use fancyassertions:

$ ./bin/hledger-check-fancyassertions.hs 

.../bin/hledger-check-fancyassertions.hs:158:19: error:
    • Couldn't match type ‘Text’ with ‘[Char]’
      Expected type: String
        Actual type: Text
    • In the second argument of ‘(<>)’, namely
        ‘"(after posting: "
           <> pack (init $ H.showPosting lastp) <> ")\n\n"’
      In the second argument of ‘(<>)’, namely
        ‘H.showTransaction t
           <>
             "(after posting: " <> pack (init $ H.showPosting lastp) <> ")\n\n"’
      In the expression:
        "after transaction:\n"
          <>
            H.showTransaction t
              <>
                "(after posting: " <> pack (init $ H.showPosting lastp) <> ")\n\n"
    |
158 |                   "(after posting: " <> T.pack (init $ H.showPosting lastp) <> ")\n\n"
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.../bin/hledger-check-fancyassertions.hs:160:19: error:
    • Couldn't match type ‘Text’ with ‘[Char]’
      Expected type: String
        Actual type: Text
    • In the expression:
        "after posting:\n" <> pack (H.showPosting lastp)
      In a case alternative:
          Nothing -> "after posting:\n" <> pack (H.showPosting lastp)
      In the expression:
        case H.ptransaction lastp of
          Just t
            -> "after transaction:\n"
                 <>
                   H.showTransaction t
                     <>
                       "(after posting: " <> pack (init $ H.showPosting lastp) <> ")\n\n"
          Nothing -> "after posting:\n" <> pack (H.showPosting lastp)
    |
160 |                   "after posting:\n" <> T.pack (H.showPosting lastp)
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.../bin/hledger-check-fancyassertions.hs:169:55: error:
    • Couldn't match type ‘[Char]’ with ‘Text’
      Expected type: Text
        Actual type: String
    • In the expression: after <> "relevant balances:"
      In the first argument of ‘(++)’, namely
        ‘["assertion '" <> pstr <> "' violated",
          after <> "relevant balances:"]’
      In the expression:
        ["assertion '" <> pstr <> "' violated",
         after <> "relevant balances:"]
          ++ map ("    " <>) accounts
    |
169 |           in [ "assertion '" <> pstr <> "' violated", after <> "relevant balances:"] ++ map ("    "<>) accounts
    |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Received ExitFailure 1 when running
Raw command: /nix/store/sb568rl14lqff9pcc3h3r07qm9xrp8jg-ghc-8.8.4/bin/ghc-8.8.4 -i -i/home/.../hledger/bin/ -hide-all-packages -fdiagnostics-color=always -packagebase -packagebase-compat -packagefilepath -packagehledger-lib -packagemegaparsec -packageoptparse-applicative -packagetext -packagetime -packagetransformers /home/.../hledger/bin/hledger-check-fancyassertions.hs
Run from: /home/.../hledger/bin/
Standard output:

[1 of 1] Compiling Main             ( /home/.../hledger/bin/hledger-check-fancyassertions.hs, /home/cassou/Documents/projects/ledger/hledger/bin/hledger-check-fancyassertions.o )
@DamienCassou DamienCassou added the A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. label Jan 11, 2021
@simonmichael
Copy link
Owner

This is supposed to be part of CI now, but something is wrong. Thanks for the report!

@simonmichael simonmichael added the tools hledger developer tools, scripts, processes.. label Jan 11, 2021
simonmichael added a commit that referenced this issue Jan 12, 2021
Using stack's script command meant that the scripts needed to be
compatible, and regularly tested, with a hledger release in stackage,
rather than the latest hledger source. This created hassles for
maintainers, contributors and sometimes for users.

To simplify things overall, we now require script users to check out
the hledger source tree and run the scripts (or, bin/compile.sh) from
there once so they compile themselves. Some notes on alternative
setups are included (in one of the scripts, and referenced by the
others). This ensures that users and our CI tests are building scripts
the same way.

Current stack does not allow a stack options line to be used with the
"stack ghc" command, unfortunately, so instead we are using env's -S
flag, which hopefully has sufficiently wide support by now, and
putting all arguments in the shebang line.

This method will probably require complete explicit --package options,
unlike "stack script", so more testing and tweaking is expected.
Probably we're going to end up with some long shebang lines.

This isn't pretty but seems like a possible way to keep things
manageable.
simonmichael added a commit that referenced this issue Jan 12, 2021
env -S isn't a thing on linux of course. Go back to using standard
env, which means using a stack options line, which means not using
"ghc". This new setup is probably simpler anyway. I've just had to
give up on the goal of having each script's required packages being
defined in one place; now (to they extent they are required) they
must be defined both in the script header and in compile.sh.
simonmichael added a commit that referenced this issue Jan 12, 2021
They need more work to become CI-ready.
Contributors can run them locally with "make functest".
@simonmichael simonmichael added the docs Documentation-related. label Jan 12, 2021
@simonmichael
Copy link
Owner

simonmichael commented Jan 12, 2021

Testing these scripts in CI turns out to be a big rabbit hole, and I have just given up for the moment. However the bin/ docs and make functest are now up to date with the new policy: add-on scripts are expected to build with the corresponding version of hledger from source.

simonmichael added a commit that referenced this issue Jan 13, 2021
simonmichael added a commit that referenced this issue Jan 13, 2021
Using stack's script command meant that the scripts needed to be
compatible, and regularly tested, with a hledger release in stackage,
rather than the latest hledger source. This created hassles for
maintainers, contributors and sometimes for users.

To simplify things overall, we now require script users to check out
the hledger source tree and run the scripts (or, bin/compile.sh) from
there once so they compile themselves. Some notes on alternative
setups are included (in one of the scripts, and referenced by the
others). This ensures that users and our CI tests are building scripts
the same way.

Current stack does not allow a stack options line to be used with the
"stack ghc" command, unfortunately, so instead we are using env's -S
flag, which hopefully has sufficiently wide support by now, and
putting all arguments in the shebang line.

This method will probably require complete explicit --package options,
unlike "stack script", so more testing and tweaking is expected.
Probably we're going to end up with some long shebang lines.

This isn't pretty but seems like a possible way to keep things
manageable.

(cherry picked from commit 2db8733)
simonmichael added a commit that referenced this issue Jan 13, 2021
env -S isn't a thing on linux of course. Go back to using standard
env, which means using a stack options line, which means not using
"ghc". This new setup is probably simpler anyway. I've just had to
give up on the goal of having each script's required packages being
defined in one place; now (to they extent they are required) they
must be defined both in the script header and in compile.sh.

(cherry picked from commit 32ccbba)
simonmichael added a commit that referenced this issue Jan 13, 2021
simonmichael added a commit that referenced this issue Jan 13, 2021
simonmichael added a commit that referenced this issue Jan 13, 2021
simonmichael added a commit that referenced this issue Jan 13, 2021
simonmichael added a commit that referenced this issue Jan 13, 2021
simonmichael added a commit that referenced this issue Jan 13, 2021
They need more work to become CI-ready.
Contributors can run them locally with "make functest".

(cherry picked from commit 93bf6cf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. docs Documentation-related. tools hledger developer tools, scripts, processes..
Projects
None yet
Development

No branches or pull requests

2 participants