theam / aws-lambda-haskell-runtime

⚡Haskell runtime for AWS Lambda
https://theam.github.io/aws-lambda-haskell-runtime/
Other
269 stars 48 forks source link

Build fail on official Stack template #41

Closed jlkiri closed 3 years ago

jlkiri commented 5 years ago

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

NickSeagull commented 5 years ago

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 commented 5 years ago

Closing for now, feel free to reopen if needed.

john-rodewald commented 4 years ago

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 commented 4 years ago

What GHC versions are you using?

john-rodewald commented 4 years ago

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 commented 4 years ago

Hey guys, this is completely expected, as https://github.com/theam/aws-lambda-haskell-runtime/pull/63 introduced some breaking changes.

Even more breaking changes are coming with https://github.com/theam/aws-lambda-haskell-runtime/pull/72, but this time I've updated the template and documentation.

parthshah31 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

parthshah31 commented 3 years ago

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

LTS 15.0

NickSeagull commented 3 years ago

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.