-
Notifications
You must be signed in to change notification settings - Fork 841
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
Inhibit errors from terminal-size #4968
Conversation
When attempting to detect the size of a Windows terminal, stty can sometimes fail with an error message, which the terminal-size package then prints to the console. This causes unexpected error messages when attempting to use Stack in such a terminal. These error messages can also interfere with tools such as Intero, which rely on Stack's output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks ok, I'm getting somebody more familiar with semantics to take a look, too.
@dbaynard Have you had any progress on this PR yet? |
No — thanks for the reminder! I've just checked through, myself (including your |
@bradrn Have you seen hspec/silently#7? Seems like this may introduce that issue, to stack. |
@bradrn I'd recommend just getting the fixed version of the windows module from your PR https://github.com/bradrn/terminal-size/blob/591033712003b58f8c61dba0fc60e95439df9c9b/src/System/Console/Terminal/Windows.hs copied directly into stack with some CPP on windows. Until and if the PR biegunka/terminal-size#13 gets merged (I wouldn't get hopes up) |
@dbaynard Thanks for responding! I had a look at the (Also, I’m curious to know: why does the addition of a dependency require approval?) @lehins I’d prefer to avoid copying the code over — that’s a massive amount of code duplication between |
@bradrn
Totally agree with you, I'd like to avoid it as well whenever possible. Only reason I suggested such a work around is because
|
@bradrn By adding a dependency you are bringing it's whole code base with it in one PR. Even if you use one function from that package, that function might have problems. Unless it is a vetted package we'd need to do a thorough review, not only of the function that you use, but the package as whole. Just think about how many people use |
That certainly is a big issue! I don’t think this is nearly as good of a solution now…
That does make sense. |
Looks like progress on this PR has slowed down a bit, but after thinking about it I think I have a solution. I was beginning to think that @lehins was right in saying that the code from |
@bradrn Unfortunately that solution has a problem. In order to be able to upload |
I didn’t realise that Stack was on Hackage! There goes another attempted solution…
But it isn’t just one function! It’s two functions (for Posix and Windows), plus all the functions they use, plus all the functions they use, plus all the imports, plus all the CPP for choosing between OSs …which is only ~150 lines, now that I check. Maybe this is more feasible than I thought! |
I thought the issue was on Windows only? If that is still the case than all that would be necessary is to copy the |
This is a bit complex:
|
A friendly ping here, because this issue is effectively a show stopper on Windows... 😞 The Can this be done soon plus a new |
@svenpanne Note that this is solvable for now with my version of Stack, if you’re willing to compile it from source; I’ve been using it very successfully with Intero. But I agree that this is a big problem which does need to be fixed. |
After some head-scratching and digging out my old MS-DOS books, I came up with the following workaround: Just put a file @IF "%1"=="size" exit 255 When |
@svenpanne That’s a very elegant solution! I tried something similar before, but I didn’t think of making my own I’m still wondering though: Does that solve the problems with Emacs? I seem to remember there being some cases where Emacs doesn’t use the same PATH as Windows. (Or I could be wrong, but it’s best to check anyway!) |
Yes, the Nevertheless, |
What's the status of this PR for merge? I keep hitting |
@tuomohopia It would be nice to know. The problem is really that all the approaches we’ve come up with so far have had big problems; I would list them all, but it’s easier to just to refer to the discussion above. |
Well, actually it's quite easy to fix the problem. Let's analyze things: First of all, using
This is the real fix, this pull request is just sweeps the problem under the carpet, and my alternative of putting a one-line batch script in the Taking over maintainership of |
How does using But I do agree that my solution just ‘sweeps the problem under the carpet’, as you put it; I’m not too familiar with this area, and that was the best solution I could figure out with my limited knowledge.
I’m starting to agree that this is the best way to go here, despite the code duplication. At this stage I can’t think of any other solution. |
It's because of the difference between "finding a command command interpreter" (with |
EDIT: see #4968 (comment) |
Alas, this is not a workaround because |
That makes sense @svenpanne — thanks for explaining! Pity the documentation doesn’t make that clear… |
I'm reviewing this PR now. I'm fine with absorbing this code. Does someone want to update this PR to do that? I'm not in favor of using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not want to go in the direction of silently
.
@snoyberg I totally agree with you! Since I created this PR, I have learnt that this is a dangerous solution, mostly due to hspec/silently#6 (mentioned earlier in the comments). The problem is that we haven’t yet found any really satisfactory solution to this — the best idea we have so far is #4968 (comment), which suggests modifying |
Closing in favor of #5183. That one is blocked on a CI issue, but should be mergeable soon. |
On a quick glance, it looks like that PR just inlines some of the code from |
Closes #4901.