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

Build fail on official Stack template #41

Closed
jlkiri opened this issue Aug 13, 2019 · 11 comments
Closed

Build fail on official Stack template #41

jlkiri opened this issue Aug 13, 2019 · 11 comments

Comments

@jlkiri
Copy link

jlkiri commented Aug 13, 2019

After doing stack build on the official template from the docs

stack new my-haskell-lambda https://github.com/theam/aws-lambda-haskell-runtime/raw/master/stack-template.hsfiles --resolver=lts-13.25 --omit-packages

build fails with the following error:

app\Main.hs:7:1: error:
    Illegal variable name: `'
    When splicing a TH declaration:
      run (LambdaOptions {functionHandler = functionHandler,
                    contextObject = contextObject,
                    eventObject = eventObject,
                    executionUuid = executionUuid}) = case functionHandler of
                                                          "src\\Lib.handler" -> do {result_0 <- () (Aws.Lambda.Meta.Dispatch.decodeObj eventObject) (Aws.Lambda.Meta.Dispatch.decodeObj contextObject);
                                                                                    Data.Either.either (GHC.Base.pure GHC.Base.. (Data.Either.Left GHC.Base.. Aws.Lambda.Meta.Dispatch.encodeObj)) (GHC.Base.pure GHC.Base.. (Data.Either.Right GHC.Base.. (LambdaResult GHC.Base.. Aws.Lambda.Meta.Dispatch.encodeObj))) result_0}
                                                          _ -> GHC.Base.pure GHC.Base.$ Data.Either.Left ("Handler " GHC.Base.<> (functionHandler GHC.Base.<> " does not exist on project"))
  |
7 | generateLambdaDispatcher
  | ^^^^^^^^^^^^^^^^^^^^^^^^


--  While building package my-haskell-lambda-0.1.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.5.exe --builddir=.stack-work\dist\e626a42b build lib:my-haskell-lambda exe:bootstrap --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

I am relatively new to Haskell, so not sure whether this is a problem with my environment or this project.

OS: Windows 10
Stack: 2.1.3

@jlkiri jlkiri changed the title Build fail on official template Build fail on official Stack template Aug 13, 2019
@NickSeagull
Copy link
Member

For some reason I cannot seem to be able to reproduce this on my side. I suspect that this is due to the format of Windows paths.

A recommendation would be to use Windows Subsystem for Linux

@NickSeagull
Copy link
Member

Closing for now, feel free to reopen if needed.

@john-rodewald
Copy link

Getting the same error.
Has anyone figured out a workaround?

MacOS 10.15.5
Stack Version 2.3.1 x86_64 hpack-0.33.0

lambda-telegram-bot> configure (lib + exe)
Configuring lambda-telegram-bot-0.1.0...
lambda-telegram-bot> build (lib + exe)
Preprocessing library for lambda-telegram-bot-0.1.0..
Building library for lambda-telegram-bot-0.1.0..
Preprocessing executable 'bootstrap' for lambda-telegram-bot-0.1.0..
Building executable 'bootstrap' for lambda-telegram-bot-0.1.0..
[1 of 2] Compiling Main

/[...]/lambda-telegram-bot/app/Main.hs:7:1: error:
    • Couldn't match type ‘DispatcherStrategy
                           -> DispatcherOptions
                           -> template-haskell-2.15.0.0:Language.Haskell.TH.Lib.Internal.DecsQ’
                     with ‘template-haskell-2.15.0.0:Language.Haskell.TH.Syntax.Q
                             [template-haskell-2.15.0.0:Language.Haskell.TH.Syntax.Dec]’
      Expected type: template-haskell-2.15.0.0:Language.Haskell.TH.Lib.Internal.DecsQ
        Actual type: DispatcherStrategy
                     -> DispatcherOptions
                     -> template-haskell-2.15.0.0:Language.Haskell.TH.Lib.Internal.DecsQ
    • Probable cause: ‘generateLambdaDispatcher’ is applied to too few arguments
      In the expression: generateLambdaDispatcher
  |
7 | generateLambdaDispatcher
  | ^^^^^^^^^^^^^^^^^^^^^^^^


--  While building package lambda-telegram-bot-0.1.0 using:
      /[...]/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.0.1.0 build lib:lambda-telegram-bot exe:bootstrap --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1```

@NickSeagull
Copy link
Member

What GHC versions are you using?

@NickSeagull NickSeagull reopened this Jun 17, 2020
@john-rodewald
Copy link

john-rodewald commented Jun 17, 2020

This happened using GHC 8.8.3. I managed to get it to work fine by adding the following to stack.yaml after finding some pointers to using lts 15.0.
I was previously on aws-lambda-haskell-runtime-2.0.6 and lts-16.1 and never got the project to build with them.

resolver: lts-15.0

packages:
- .

extra-deps:
- aws-lambda-haskell-runtime-2.0.4@sha256:f787843d004f139a6292aff29409fbe5be0101be0e5fbaa86b6a1c51899cc6cb,2899

@dnikolovv
Copy link
Contributor

Hey guys, this is completely expected, as #63 introduced some breaking changes.

Even more breaking changes are coming with #72, but this time I've updated the template and documentation.

@parthshah31
Copy link

Running into same issue. Building on macOS Mojave (10.14.6). Didn't see anything in docs at https://theam.github.io/aws-lambda-haskell-runtime/05-common-errors.html

@parthshah31
Copy link

Got the following error. Any thoughts on how to fix -- did some digging on the -lcrt0.o part, seems it may be related to the makefile?

my-haskell-lambda> build (lib + exe)
Preprocessing library for my-haskell-lambda-0.1.0..
Building library for my-haskell-lambda-0.1.0..
Preprocessing executable 'bootstrap' for my-haskell-lambda-0.1.0..
Building executable 'bootstrap' for my-haskell-lambda-0.1.0..
Linking .stack-work/dist/x86_64-osx/Cabal-3.0.1.0/build/bootstrap/bootstrap ...
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building package my-haskell-lambda-0.1.0 using:
      /Users/parthsidious/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.0.1.0 build lib:my-haskell-lambda exe:bootstrap --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

@NickSeagull
Copy link
Member

@parthshah31 what LTS are you on? Can you provide a repo to reproduce?

@parthshah31
Copy link

@NickSeagull here's a link: https://github.com/parthshah31/aws-lambda-hs-test

LTS 15.0

@NickSeagull
Copy link
Member

Ok @parthshah31, I asked a friend to try building this on his Macbook (mine is at tech support atm) and indeed he can reproduce.

Apparently, MacOS doesn't support static linking, and this should only be done when you are ready to deploy your lambda by building with stack --docker. For development, I recommend removing the static linking options from the cabal file, and add them when deploying.

I've created #95 in order to document this if someone wants to contribute. Feel free to re-open if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants