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

Text is truncated when launching external terminal on OSX in debugger #38578

Closed
DonJayamanne opened this issue Nov 17, 2017 · 4 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Nov 17, 2017

  • VSCode Version: Version 1.18.1 (1.18.1)
  • OS Version: Mac Sierra

Steps to Reproduce:

  1. Get Python Extension from source (https://github.com/DonJayamanne/pythonVSCode.git) into your vscode extensions directory
  2. Check out the branch RunWithoutDebug
  3. Compile and launch extension
  4. Create a simple python file with the lines print("1234")
  5. Go into the debug option and selection 'Python Terminal (external)`
  6. Run

Show me the code
The code used to send the request to VS Code can be found here (using runInTerminalRequest):

const termArgs: DebugProtocol.RunInTerminalRequestArguments = {
    kind: consoleKind,
    title: 'Python Debug Console',
    cwd: processCwd,
    args: [command].concat(commandArgs),
    env: environmentVariables
};
this.debugSession.runInTerminalRequest(termArgs, 5000, (response) => {
    if (response.success) {
        resolve();
    } else {
        reject(response);
    }
});
break;

Here you can see that I'm copying all env variables from current process into a variable (which could be deemed unnecessary -technical debt).
If I were to comment this line of code, then launching in the external terminal works as expected.

for (let setting in process.env) {
    if (!environmentVariables[setting]) {
        environmentVariables[setting] = process.env[setting];
    }
}

Observations:
On windows, this works as expected (a terminal is a launched and code is executed with breakpoints).
On a Mac (Sierra), a terminal window is launched, however you can see that not all of the text is in the command prompt. As only part of the text is printed out into the terminal window nothing gets executed, hence the debugger just hangs.

The integrated terminal option works on both Windows and Mac.

I think the problem is there's too much information being dumped into the terminal.
Currently i'm copying all environment variables from the process and passing this into the command (i.e. too many env variables to be set in the terminal).

Output from external and integrated terminals (text truncation can be seen):
Here's a copy of the text in the external terminal (on Mac OS):

cd '/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/ExtBench'; env 'TMPDIR=/var/folders/22/0kj01mp12l3dsd1vw9vhfs6c0000gn/T/' '__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0' 'SHELL=/usr/local/bin/bash' 'HOME=/Users/donjayamanne' 'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.CSe8T2MwoE/Render' 'SSH_AUTH_SOCK=/private/tmp/com.apple.$ cd$ cd '/Users/donjayamanne/Desktop/Development/PythonStuff/Blah/ExtBench'; env 'TMPDIR=/var/folders/22/0kj01mp12l3dsd1vw9vhfs6c0000gn/T/' '__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0' 'SHELL=/usr/local/bin/bash' 'HOME=/Users/donjayamanne' 'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.CSe8T2MwoE/Render' 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.Z1MbjFE2W9/Listeners' 'PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/donjayamanne/.nvm/versions/node/v8.9.1/bin:/Users/donjayamanne/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' 'LOGNAME=donjayamanne' 'XPC_SERVICE_NAME=com.microsoft.VSCode.78532' 'USER=donjayamanne' 'XPC_FLAGS=0x0' 'GOOGLE_API_KEY=111111111111111111111111111111111111111' 'VSCODE_NODE_CACHED_DATA_DIR_10691=/Users/donjayamanne/Library/Application Support/Code/CachedData/1111111111111111111111111111111111111111' 'VSCODE_NLS_CONFIG={"locale":"en-us","availableLanguages":{}}' 'VSCODE_PID=10691' 'VSCODE_IPC_HOOK=/Users/donjayamanne/Library/Application Support/Code/1.18.1-main.s
VSCODE_PID=10691'
ers/donjayamanne/Library/Ap

If I try debugging using the integrated terminal, it works and here's the text that gets sent to the integrated terminal (lot more information):

cd /Users/donjayamanne/Desktop/Development/PythonStuff/Blah/ExtBench ; env "TMPDIR=/var/folders/22/0kj01mp12l3dsd1vw9vhfs6c0000gn/T/" "__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0" "SHELL=/usr/local/bin/bash" "HOME=/Users/donjayamanne" "Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.CSe8T2MwoE/Render" "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.Z1MbjFE2W9/Listeners" "PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/donjayamanne/.nvm/versions/node/v8.9.1/bin:/Users/donjayamanne/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" "LOGNAME=donjayamanne" "XPC_SERVICE_NAME=com.microsoft.VSCode.78532" "USER=donjayamanne" "XPC_FLAGS=0x0" "GOOGLE_API_KEY=1111111111111111111111111111111111111111" "VSCODE_NODE_CACHED_DATA_DIR_10691=/Users/donjayamanne/Library/Application Support/Code/CachedData/1111111111111111111111111111111111111111" "VSCODE_NLS_CONFIG={"locale":"en-us","availableLanguages":{}}" "VSCODE_PID=10691" "VSCODE_IPC_HOOK=/Users/donjayamanne/Library/Application Support/Code/1.18.1-main.sock" "EDITOR=vim" "GPG_TTY=not a tty" "HISTCONTROL=ignoreboth" "HISTFILESIZE=32768" "HISTSIZE=32768" "LANG=en_US.UTF-8" "LC_ALL=en_US.UTF-8" "LESS_TERMCAP_md=;5;136m" "LSCOLORS=BxBxhxDxfxhxhxhxhxcxcx" "MANPAGER=less -X" "NODE_REPL_HISTORY=/Users/donjayamanne/.node_history" "NODE_REPL_HISTORY_SIZE=32768" "NODE_REPL_MODE=sloppy" "NVM_BIN=/Users/donjayamanne/.nvm/versions/node/v8.9.1/bin" "NVM_CD_FLAGS=" "NVM_DIR=/Users/donjayamanne/.nvm" "PS1=\[\033]0;\W\007\]\[m\]\n\[;5;166m\]\u\[7m\] at \[;5;136m\]\h\[7m\] in \[;5;64m\]\w$(prompt_git "\[7m\] on \[;5;61m\]" "\[;5;33m\]")\n\[7m\]$ \[B\]" "PS2=\[;5;136m\]→ \[B\]" "PWD=/" "PYTHONIOENCODING=UTF-8" "SHLVL=1" "TERM=xterm-256color" "_=/Applications/Visual Studio Code.app/Contents/MacOS/Electron" "ELECTRON_NO_ASAR=1" "PYTHONUNBUFFERED=1" /Users/donjayamanne/miniconda3/bin/python /Users/donjayamanne/.vscode/extensions/pythonVSCode/pythonFiles/PythonTools/visualstudio_py_launcher.py /Users/donjayamanne/Desktop/Development/PythonStuff/Blah/ExtBench 50821 34806ad9-833a-4524-8cd6-18ca4aa74f14 DUMMYVALUE /Users/donjayamanne/Desktop/Development/PythonStuff/Blah/ExtBench/one.py

Note:
I have tried debugging vscode from source, unfortunately I don't know how to get the vscode node debugger in there. I get some error about debug type node not being supported. Hence couldn't get anywhere with this.

When reverting to my old code (launching the external terminal using my own code), it works. Here's the old code https://github.com/DonJayamanne/pythonVSCode/blob/master/src/client/common/open.ts

@vscodebot vscodebot bot added the terminal Integrated terminal issues label Nov 17, 2017
@Tyriar Tyriar added debug Debug viewlet, configurations, breakpoints, adapter issues and removed terminal Integrated terminal issues labels Dec 15, 2017
@Tyriar Tyriar assigned weinand and unassigned Tyriar Dec 15, 2017
@weinand weinand added the bug Issue identified by VS Code Team member as probable bug label Dec 15, 2017
@weinand
Copy link
Contributor

weinand commented Dec 15, 2017

@DonJayamanne if you run VS Code from source and want to use the node debugger, just copy the 2 extensions

2017-12-15_17-20-57

from your Insiders release into the extension folder ~/.vscode-oss-dev/extensions

@Eskibear
Copy link
Member

We have the similar issue here.
Recently we've changed default console of the Java debugger to integratedTerminal, and we have a very similar issue microsoft/vscode-java-debug#614 , truncated text, same in OSX. To mention that, in my case, the length of truncated text is 1024, which must is sucpicious. Any clues?

@weinand Is there any update?
@DonJayamanne Have you resolved the issue in Python extension, or you just work it around?

Thanks in advance for your help.

@tom-thorne
Copy link

tom-thorne commented Mar 27, 2020

I see the similar issue on VS Code 1.43.2 on Mac OSX Mojave but with the integratedTerminal

My default shell is zsh

Steps to reproduce:

  • make a folder and cd to it
  • npm init
  • launch vscode and save index.js as
console.log('TEST_ARG:');
console.log(process.env.TEST_ARG);
  • create a launch.json (see below)
  • hit F5 ... works as expected.
  • change launch.json to set "console": "integratedTerminal"
  • hit F5 ... Terminal shows as below and debugger fails to launch
~/code/env-test
❯  env TEST_ARG=hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/index.js",
            "env": {
                "TEST_ARG": "hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-hi-END"
            },
            "console": "internalConsole"
        }
    ]
}

@weinand
Copy link
Contributor

weinand commented Nov 11, 2020

I have introduced a 1 second delay before using a newly created external terminal. This gives the shell running inside the terminal more time initialise itself.

@weinand weinand added this to the November 2020 milestone Nov 11, 2020
@RMacfarlane RMacfarlane added the verified Verification succeeded label Dec 4, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants
@weinand @DonJayamanne @Tyriar @Eskibear @RMacfarlane @kieferrm @tom-thorne and others