You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make output of stack path independent of logging. #604
The output of stack path is produced using Control.Monad.Logger.logInfo. This makes stack path --<some specific path> unusable, since the output can't be separated from other log output.
Expected
I'm writing script that copies Stack-produced binaries. I would like to do e.g.
However, I'm exporting STACK_YAML -- we build against both GHC 7.8 and 7.10 -- and so the output of stack path --local-install-root includes a warning on the first line which causes the cp to fail:
Getting project config file from STACK_YAML environment
/home/conathan/v/saw-script.git/.stack-work/install/x86_64-linux/lts-2.15/7.8.4
Note that using --verbosity <verbosity level> doesn't help, since the warning and the path are both printed using logInfo, so you get both or neither.
Ideas for fixes
In any case, the regular output of the stack path command should not be produced using logInfo. So, change $logInfo to T.putStrLn at
I would also suggest that log messages go to stderr by default. If you have a reason for sending log messages to stdout, then --verbosity silent could still be used to suppress them, so this is not essential.
Workaround
In the mean time I could reimplement stack path --local-install-root in terms of stack path:
stack --verbosity info path | sed -ne 's/local-install-root: //p'
Another workaround is to do stack --stack_yaml=$STACK_YAML path --local-install-root, but that will break if I stop exporting STACK_YAML later.
We should probably suppress the Getting project config file from STACK_YAML environment message when stack is not running in a terminal, like is done here:
@mgsloan: OK. Seems silly to make a pull-request for a one line change, but I'll do that and also try rewording the CONTRIBUTING.md a little in hopes of making well-intentioned people like me submit better error reports in the future (see below) :)
@chrisdone: no, I was using 0.1.2.0; sorry I did not include that info. Interestingly, you guys ask for this info explicitly in the CONTRIBUTING.md, which I thought I read, but my takeaway was to add some header sections ("Expected", "Actual") :P I think the problem was that there's a lot of example text which my brain decided was irrelevant and ignored.
@ntc2 True, I'm just encouraging contribution! We're trying to keep the barrier to contribution as low as possible. We can give you commit access if you'd like to commit such changes directly to master.
@mgsloan: no worries, I really appreciate how responsive you guys are; I just meant it would be a lot quicker for one of you who already has the code base to spend 1 minute making this change. But now that I have the code I will also look into changing log messages to go to stderr instead :) I'll stick with the pull request for now; that will ensure I don't make any changes you guys don't like.
@mgsloan: I created a pull request: #615. I'm not sure you will like the "make all log messages go to stderr" change. If not, could you explain why you guys want to send log messages stdout?
@chrisdone: so, ERROR and WARNING level log messages were going to stderr, like you said. But, the STACK_YAML warning that causes the problem is an INFO level warning, and those were still going to stdout. Another solution to my specific problem would be to send the STACK_YAML warning to level WARNING instead, but I'm still concerned about the general problem of unpredictable stdout due to logging.
Activity
mgsloan commentedon Jul 16, 2015
Sounds like a good change to me! Feel free to make a PR :D
chrisdone commentedon Jul 16, 2015
Errors and warnings were changed in the last couple days to go to stderr by default. Did you try recent master?
borsboom commentedon Jul 16, 2015
We should probably suppress the
Getting project config file from STACK_YAML environmentmessage when stack is not running in a terminal, like is done here:stack/src/Stack/Config.hs
Line 249 in 8b023a8
ntc2 commentedon Jul 16, 2015
@mgsloan: OK. Seems silly to make a pull-request for a one line change, but I'll do that and also try rewording the CONTRIBUTING.md a little in hopes of making well-intentioned people like me submit better error reports in the future (see below) :)
@chrisdone: no, I was using 0.1.2.0; sorry I did not include that info. Interestingly, you guys ask for this info explicitly in the CONTRIBUTING.md, which I thought I read, but my takeaway was to add some header sections ("Expected", "Actual") :P I think the problem was that there's a lot of example text which my brain decided was irrelevant and ignored.
@manny-fp: that sounds like a great idea!
mgsloan commentedon Jul 16, 2015
@ntc2 True, I'm just encouraging contribution! We're trying to keep the barrier to contribution as low as possible. We can give you commit access if you'd like to commit such changes directly to master.
ntc2 commentedon Jul 16, 2015
@chrisdone: using current master logging still goes to stdout, e.g.:
Of course, those commands only produce INFO and DEBUG level log messages.
(EDIT: I pasted the wrong commands; the output is the same.)
ntc2 commentedon Jul 16, 2015
@mgsloan: no worries, I really appreciate how responsive you guys are; I just meant it would be a lot quicker for one of you who already has the code base to spend 1 minute making this change. But now that I have the code I will also look into changing log messages to go to stderr instead :) I'll stick with the pull request for now; that will ensure I don't make any changes you guys don't like.
Make `stack path` output independent of logging. (Issue commercialhas…
Send log messages to stderr. (Issues commercialhaskell#604, commercia…
ntc2 commentedon Jul 17, 2015
@mgsloan: I created a pull request: #615. I'm not sure you will like the "make all log messages go to stderr" change. If not, could you explain why you guys want to send log messages stdout?
@chrisdone: so, ERROR and WARNING level log messages were going to stderr, like you said. But, the
STACK_YAMLwarning that causes the problem is an INFO level warning, and those were still going to stdout. Another solution to my specific problem would be to send theSTACK_YAMLwarning to level WARNING instead, but I'm still concerned about the general problem of unpredictable stdout due to logging.radix commentedon Jul 17, 2015
+1 for making all logging out-of-band (i.e. go to stderr), that nicely separates intended, crafted output from everything else.
mgsloan commentedon Jul 17, 2015
@ntc2 Cool, thanks for making a PR - we're on board with logging going to stderr.
Print `stack dot` output instead of logging it. (Issue commercialhask…
Merge pull request #615 from GaloisInc/master
mgsloan commentedon Jul 17, 2015
Merged!