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

Passing cabal flags? #191

Closed
chreekat opened this issue Jun 5, 2015 · 11 comments
Closed

Passing cabal flags? #191

chreekat opened this issue Jun 5, 2015 · 11 comments

Comments

@chreekat
Copy link
Member

chreekat commented Jun 5, 2015

E.g. -fdev for yesod apps. Can I do this?

@snoyberg
Copy link
Contributor

snoyberg commented Jun 6, 2015

I implemented this on Friday, it's the --flag option:

  --flag PACKAGE:[-]FLAG   Override flags set in stack.yaml (applies to local
                           packages and extra-deps)

@snoyberg snoyberg added this to the Third release milestone Jun 6, 2015
@chreekat
Copy link
Member Author

chreekat commented Jun 6, 2015

great success

@chreekat chreekat closed this as completed Jun 6, 2015
@chreekat chreekat removed their assignment Jun 9, 2015
@dhobbs
Copy link

dhobbs commented Aug 17, 2015

Can someone give an example of what PACKAGE would be? What would be the stack equivalent of this cabal command:

cabal install gtk -fhave-quartz-gtk

@snoyberg
Copy link
Contributor

stack build gtk --flag gtk:have-quartz-gtk

@dhobbs
Copy link

dhobbs commented Aug 17, 2015

I can't see it being passed through.

stack build gtk --flag gtk:have-quartz-gtk gives me an error:

~ $ stack build gtk --flag gtk:have-quartz-gtk
Run from outside a project, using implicit global config
Using resolver: lts-3.1 from global config file: /Users/darren/.stack/global/stack.yaml
Invalid flag specification:
- Package 'gtk' not found (specified on command line)

I'm trying to install threadscope (which requires gtk) on a mac, using stack. The error below is what happens if -fhave-quartz-gtk isn't supplied, which is why I suspect it isn't making it through.

stack build gtk --flag *:have-quartz-gtk
Run from outside a project, using implicit global config
Using resolver: lts-3.1 from global config file: /Users/darren/.stack/global/stack.yaml
gtk-0.13.9: configure
gtk-0.13.9: build

--  While building package gtk-0.13.9 using:
      /Users/darren/.stack/programs/x86_64-osx/ghc-7.10.2/bin/runhaskell -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/Users/darren/.stack/snapshots/x86_64-osx/lts-3.1/7.10.2/pkgdb/ /var/folders/w_/hxywk7kd52g2jjvqdtw6qx5w0000gn/T/stack75520/gtk-0.13.9/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ build --ghc-options -hpcdir .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/hpc/.hpc/ -ddump-hi -ddump-to-file
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/darren/.stack/global/.stack-work/logs/gtk-0.13.9.log

@snoyberg
Copy link
Contributor

This should probably transition to a new issue. Please include the stack version you're using.

@dhobbs
Copy link

dhobbs commented Aug 17, 2015

New issue created: #807

@jasagredo
Copy link

I comment on this issue because I think it is the most appropriate one instead of creating a new one.

stack build --flag package:flag works perfectly but when you want to run a binary with a specific flag activated, stack run package-exe --flag package:flag does not work and reports that --flag is not available:

Invalid option `--flag'

Usage: stack run [-- ARGS (e.g. stack run -- file.txt)]
                 [--[no-]ghc-package-path] [--[no-]stack-exe] [--package ARG]
                 [--rts-options RTSFLAG] [--cwd DIR] [--help]
  Build and run an executable. Defaults to the first available executable if
  none is provided as the first argument.

Is this expected? how should I proceed if I want to pass a cabal flag when executing a binary and I want it to be given on the command line (this means that writing it in stack.yaml is not an option for me)?

@mattaudesse
Copy link
Member

@jasagredo I realize it's probably not the answer you're hoping for, but how about just making this a two-step process using the current functionality?

$ stack build --flag package:flag && stack run
                                  ^^^^^^^^^^^^

@jasagredo
Copy link

jasagredo commented Apr 15, 2020

@mattaudesse
That approach works. For now I can stick to that.
Though with some guidance that flag option could be added to stack run if approved.
Thanks.

@bisgardo
Copy link

bisgardo commented May 4, 2020

@jasagredo I realize it's probably not the answer you're hoping for, but how about just making this a two-step process using the current functionality?

$ stack build --flag package:flag && stack run
                                  ^^^^^^^^^^^^

For me stack run rebuilds the binary, so I use stack exec <binary> instead.

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

No branches or pull requests

6 participants