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

stack not automatically installing alex (build-tools vs build-depends?) #782

Closed
pseudonom opened this issue Aug 13, 2015 · 12 comments
Closed
Milestone

Comments

@pseudonom
Copy link

I may have strange behavioral expectations, but based on:

How do I get extra build tools?

stack will automatically install build tools required by your packages or their dependencies, in particular alex and happy.

from https://github.com/commercialhaskell/stack/wiki/FAQ

I'm expecting stack build to get alex if necessary.

Instead, for my project I get

language-javascript-0.5.14.2: configure
Progress: 1/14
--  While building package language-javascript-0.5.14.2 using:
    ...
    Process exited with code: ExitFailure 1
    Logs have been written to: .../.stack-work/logs/language-javascript-0.5.14.2.log

    Configuring language-javascript-0.5.14.2...
    Setup.hs: The program 'alex' version >=3.1.4 is required but it could not be
    found.

Perhaps because alex is specified in build-tools rather than build depends? https://github.com/erikd/language-javascript/blob/master/language-javascript.cabal#L41

This is with Version 0.1.3.1, Git revision 908b04205e6f436d4a5f420b1c6c646ed2b804d7.

@snoyberg
Copy link
Contributor

What does your stack.yaml file look like? I think this feature won't work
with custom and GHC resolvers.

On Thu, Aug 13, 2015, 10:05 PM Eric Easley [email protected] wrote:

I may have strange behavioral expectations, but based on:

How do I get extra build tools?

stack will automatically install build tools required by your packages or
their dependencies, in particular alex and happy.

from https://github.com/commercialhaskell/stack/wiki/FAQ

I'm expecting stack build to get alex if necessary.

Instead, for my project I get

language-javascript-0.5.14.2: configure
Progress: 1/14
-- While building package language-javascript-0.5.14.2 using:
...
Process exited with code: ExitFailure 1
Logs have been written to: .../.stack-work/logs/language-javascript-0.5.14.2.log

Configuring language-javascript-0.5.14.2...
Setup.hs: The program 'alex' version >=3.1.4 is required but it could not be
found.

Perhaps because alex is specified in build-tools rather than build
depends?
https://github.com/erikd/language-javascript/blob/master/language-javascript.cabal#L41

This is with Version 0.1.3.1, Git revision
908b042.


Reply to this email directly or view it on GitHub
#782.

@pseudonom
Copy link
Author

stack.yaml:

require-stack-version: ">= 0.1.3.1"

resolver:
  name: frontrowed-2.0
  location: stack-snapshot/frontrowed-2.0.yaml

packages:
  ...

frontrowed-2.0.yaml is based on lts-3.0:

compiler: ghc-7.10.2

flags:
  aeson:
    old-locale: false
  time-locale-compat:
    old-locale: false
  text:
    integer-simple: false

packages:
  # Extra dependencies
  ...

  # lts-3.0:
  ...

@snoyberg
Copy link
Contributor

Right, that falls into the "custom build type" so it's not being covered. The workaround for now is to just run stack build alex happy first, which will end up as a no-op if they're already installed. Can you confirm this works?

For the record, I don't have any intention of adding support for build-tool tracking for non-snapshot resolvers, since I can't think of a way to add it that won't absolutely kill performance. If someone else wants to take a crack at it, please speak up.

@snoyberg snoyberg added this to the Support milestone Aug 15, 2015
@pseudonom
Copy link
Author

Ah, so stack has some special casing for stackage resolvers and build-tool? Thanks.

I ended up just adding alex to the packages list in our custom resolver.

@snoyberg
Copy link
Contributor

Well, no matter what, you'll need to add the packages to the list of available packages in order to get it installed. The "special casing" is slightly more complicated than that, but for now the parsing of available executables only applies at the pre-process phase of a snapshot.

It looks like the issue is resolved for now, so closing.

@creswick
Copy link

Right, that falls into the "custom build type" so it's not being covered. The workaround for now is to just run stack build alex happy first, which will end up as a no-op if they're already installed. Can you confirm this works?

This is not currently working for me; stack still can't find happy after running the build command with a ghc-7.10.3 resolver.

I'm running:

$ stack --version
Version 1.1.2 x86_64 hpack-0.14.1
$ cabal --version
cabal-install version 1.24.0.0
compiled using version 1.24.0.0 of the Cabal library

with happy-1.19.5 in ~/.cabal/bin, ~/.local/bin, and after running the stack build command, under .stack-work as well.

I think alex is working, so I'm not sure why they are treated differently.

I'm seeing the following failure when running stack test:

   ...
    setup-Simple-Cabal-1.22.5.0-ghc-7.10.3: The program 'happy' is required but it
    could not be found

@sjakobi
Copy link
Member

sjakobi commented Aug 9, 2016

@creswick: Are ~/.cabal/bin and ~/.local/bin on your PATH?

If so, can you share a sample project that we can use to reproduce the issue?

@mgsloan
Copy link
Contributor

mgsloan commented Aug 9, 2016

This is not currently working for me; stack still can't find happy after running the build command with a ghc-7.10.3 resolver.

Yeah, the resolver ghc-7.10.3 doesn't specify a happy version or versions for happy's dependencies.

If I try to install a specific happy version, it nearly works:

mgsloan@computer:~$ stack --resolver ghc-7.10.3 install happy-1.19.5
Run from outside a project, using implicit global project config
Using resolver: ghc-7.10.3 specified on command line
Run from outside a project, using implicit global project config
Using resolver: ghc-7.10.3 specified on command line

While constructing the build plan, the following exceptions were encountered:

In the dependencies for happy-1.19.5:
    mtl must match >=1.0, but the stack configuration has no specified version (latest applicable is 2.2.1)

Recommended action: try adding the following to your extra-deps in /home/mgsloan/.stack/global-project/stack.yaml:
- mtl-2.2.1

You may also want to try the 'stack solver' command
Plan construction failed.

stack install --resolver ghc-7.10.3 happy-1.19.5 mtl-2.2.1 works.

@creswick
Copy link

creswick commented Aug 9, 2016

@sjakobi Yes, both those directories are on my PATH; I don't have a minimal test case -- I'm sorry about that.

@GabVenturato
Copy link

GabVenturato commented Jun 25, 2021

Hello, maybe I'm missing something because I've just started to use stack, but I'm having troubles with this topic. In the project I'm trying to build I have the following files.

stack.yaml:

resolver:
  url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml
packages:
- .

package.yaml:

...
dependencies:
- base >= 4.7 && < 5

library:
  source-dirs: src

executables:
  ltl-rmpast:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - ltl-rmpast

tests:
...

The problem is that when I run stack build I get the following:

$ stack build
Building all executables for `ltl-rmpast' once. After a successful build of all of them, only specified executables will be rebuilt.
ltl-rmpast> configure (lib + exe)
Configuring ltl-rmpast-0.1.0.0...
ltl-rmpast> build (lib + exe)
Preprocessing library for ltl-rmpast-0.1.0.0..
Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4: The program 'alex' is required but
it could not be found


--  While building package ltl-rmpast-0.1.0.0 (scroll up to its section to see the error) using:
      /Users/gabriele/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-3.2.1.0 build lib:ltl-rmpast exe:ltl-rmpast --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Based on this I've also tried to put resolver: lts-18.0 in the stack.yaml, but the error remains the same.

Any clue? 😄

Thanks.

EDIT: Further info.

  • I have ~/.local/bin in my PATH
  • In my system at the moment I don't have ghc/cabal installed. I've never run Haskell in the system I'm using to try this, but if I got it right, stack should be self-contained. Right?

@qrilka
Copy link
Contributor

qrilka commented Jun 28, 2021

@GabVenturato your package seems to depend on alex as a build tool, you could declared this dependency by adding

build-tools:
  - alex

into your package.yaml and Stack should build alex and make it available for the project

@GabVenturato
Copy link

@qrilka Yes, that solved the problem! Thanks 😄

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

7 participants