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

Error identifying terminal #385

Closed
bersbersbers opened this issue Jul 22, 2020 · 17 comments
Closed

Error identifying terminal #385

bersbersbers opened this issue Jul 22, 2020 · 17 comments
Assignees

Comments

@bersbersbers
Copy link

bersbersbers commented Jul 22, 2020

Describe the bug

  • After hitting F5, my code runs fine in the terminal
  • Then executing another line by Ctrl-Enter issues the "Error identifying terminal"
  • Focusing terminal once and executing the same line again from the same editor as before makes it work

Do you want to fix by self? (I hope your help!)

No, but I can help debug.

Environment (please complete the following information):

  • OS: VS Code on Windows 10, using VS Code Remote SHH into Linux
  • VSCode Version: 1.47.2
  • R Version: 4.0.2
  • vscode-R version: 1.4.3
@andycraig
Copy link
Collaborator

Hi @bersbersbers, thank you for reporting this.

When I hit F5 (command 'Debug: Start Debugging'), I get a popup 'Select Environment', with options 'Node.js' and 'More...'. Do you have some additional setup associated with F5?

@bersbersbers
Copy link
Author

@andycraig yes, sorry I forgot about this:

    {
        "key": "f5",
        "command": "r.runSource",
        "when": "editorTextFocus && editorLangId == 'r'"
    },

@andycraig
Copy link
Collaborator

@bersbersbers Thank you! I have a suspicion that this might be related to using a remote session. I will look into it.

If you experience this error again, could you post here with the names of all the terminals that were open at the time? (E.g., '1: R Interactive', '2: bash' etc.) That will help with investigating the problem. Thanks in advance!

@andycraig andycraig self-assigned this Aug 8, 2020
@bersbersbers
Copy link
Author

Will do! It happens less regularly now, but it did happen once yesterday.

@andycraig
Copy link
Collaborator

I had a try at duplicating this error using a Docker container and the ‘Remote - Containers’ extension, but I couldn’t get it to happen. (Not quite the same as SSH, but I had thought that just using a remote might be the problem.)

The error ‘Error identifying terminal! This shouldn't happen, so please file an issue at https://github.com/Ikuyadeu/vscode-R/issues’ should only happen if the active terminal is undefined, and there is not exactly one terminal. I think it must take a very particular set of circumstances for VS Code to get into that state.

Other information that would be useful for investigating this:

  • Whether anything else happens between F5 and Ctrl-Enter (anything at all, even just clicking somewhere)
  • Whether this seems to happen at a particular time (e.g., just after starting VS Code, just after creating a new terminal, just after closing a terminal)

Thank you!

@bersbersbers
Copy link
Author

bersbersbers commented Aug 18, 2020

Alright, here we go. I just killed a long-running R script with the trash-can symbol, and then tried to restart it with F5. That's when I got the error again. Let's try to investigate further.

  • I had provider-internet connection problems some tens of minutes before, so the VS Code session most probably went through a few reconnects before problems started. Not sure this is related, but I imagine every bit helps.

  • I almost certainly did not use Ctrl-Enter in this session, only F5.

  • As far as I can be certain, I only have or had a single terminal open, "1: R interactive".

  • One way to reproduce the issue (like 10 times in a row) towards the end of my testing was this: Press F5, code runs. Kill Terminal (trash can). Press F5, code runs. Close Panel (the x to the right of the trash can). Press F5. (No other mouse clicks in-between.) The third F5 made the error appear.

  • These repro steps stopped working after shutting down and re-opening VS Code, so I cannot provide any more information right now.

@andycraig
Copy link
Collaborator

Thank you for providing this update - this information is very helpful. This is definitely a case where every bit helps! I’ll do some more investigating.

@bersbersbers
Copy link
Author

@andycraig
Copy link
Collaborator

@bersbersbers Thank you again for posting that GIF. There is something very weird going on.

I was thinking that I could remove and rearrange some code to handle all situations but I've realised that still not quite the case. My new plan is to make it more robust where I can, which might avoid the error sometimes. In the case shown in your GIF, I'd like to make it output a bunch of debugging information so we can get a better sense of the internal state of VS Code when it happens. Then we might have a better sense of what's going on, and possibly some more information to pass on to the VS Code team - at this point I'm not sure if the problem is this extension, VS Code itself, or both.

Sorry about having to put up with this error for so long! Thank you for bearing with me.

@bersbersbers
Copy link
Author

@bersbersbers Thank you again for posting that GIF. There is something very weird going on.

Welcome!

My new plan is to make it more robust where I can, which might avoid the error sometimes. In the case shown in your GIF, I'd like to make it output a bunch of debugging information so we can get a better sense of the internal state of VS Code when it happens.

Sounds good, I'll be happy to pass on any debug output.

Sorry about having to put up with this error for so long! Thank you for bearing with me.

No worries, it happens only several times a week and I can usually fix it by activating the terminal with a single click. That's the main reason for my slow responses to your requests ;)

@andycraig
Copy link
Collaborator

Good to hear it can usually be fixed with a click at least!

I think there is actually a bug in VS Code relating to activeTerminal being undefined even though the terminal is visible, as you showed in the GIF. I’ve created an issue: microsoft/vscode#106123

@bersbersbers
Copy link
Author

Ah, great, you're now able to reproduce this. That's good, as you won't be blocked on my further repros ;) good luck!

@andycraig
Copy link
Collaborator

Hi @bersbersbers, sorry for the lack of action on this. I believe the root cause is the bug in VS Code, but even with that bug there is a workaround in vscode-R that should be handling it gracefully without error. The error is happening, though, so I think there may be a second problem. I can reproduce the VS Code bug but unfortunately not the vscode-R error.

The latest version of vscode-R outputs more information when this error occurs. The error message now asks the user to run the command 'Developer: Toggle Developer Tools' and check the console for a diagnostic message. The screenshot below shows what it should look like after running 'Developer: Toggle Developer Tools'. If you get this error again, if you could copy the section of the console starting with '[chooseTerminal]' and paste it here, that will help with debugging this problem. (I made the screenshot artificially by moving some code around since I haven't managed to reproduce the error myself.)

Thank you again for your patience on this.

terminals3

@bersbersbers
Copy link
Author

Thank you! I haven't met the bug in a while, but this is mostly due to me trying out https://marketplace.visualstudio.com/items?itemName=RDebugger.r-debugger as well. I think your instructions are well-suited for users (me or anyone else) to gather the required information.

@andycraig
Copy link
Collaborator

The VS Code bug (activeTerminal being undefined even though the terminal is visible) seems to have been fixed. So, hopefully this issue will no longer occur.

@github-actions
Copy link

github-actions bot commented Jun 9, 2022

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Jun 9, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

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

2 participants