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

Strange CLI behavior: CLI does not seem to write to either stdout (FD 1) or stderr (FD 2), making output impossible to redirect. #8585

Closed
dilijev opened this issue Jun 30, 2016 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities info-needed Issue requires more information from poster verified Verification succeeded windows VS Code on Windows issues
Milestone

Comments

@dilijev
Copy link

dilijev commented Jun 30, 2016

  • VSCode Version: Code - Insiders 1.3.0-insider (a21c123, 2016-06-30T05:07:11.570Z)
  • OS Version: Windows_NT ia32 10.0.14372

Strange CLI behavior: the VS Code CLI does not seem to write to either stdout (FD 1) or stderr (FD 2), making output impossible to pipe to e.g. grep to search for a particular flag, and making it impossible to hide output in scripting (not that I can think of a good reason you would want to script the code CLI).

Steps to Reproduce:

  1. Run code-insiders -h > NUL from cmd
  2. Observe that output is still printed
  3. Run code-insiders -h 1> NUL from cmd
  4. Observe that output is still printed
  5. Run code-insiders -h 2> NUL from cmd
  6. Observe that output is still printed
@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Jul 1, 2016
@espresso3389
Copy link

I have the completely same issue.
I'm creating a script to backup/restore extensions using --list-extensions but I cannot redirect the output from --list-extensions...

@Tyriar
Copy link
Member

Tyriar commented Jul 11, 2016

Seems fine on Linux, are these commands supposed to work on windows? It also seems to direct to stdout fine on 1.2.1.

~/dev/Microsoft/vscode @master
❯ code-insiders -h
Visual Studio Code v1.4.0-insider


Usage: code [arguments] [paths...]

Options:
  -d, --diff                  Open a diff editor. Requires to pass two file paths as arguments.
  --disable-extensions        Disable all installed extensions.
  -g, --goto                  Open the file at path at the line and column (add :line[:column] to path).
  --locale <locale>           The locale to use (e.g. en-US or zh-TW).
  -n, --new-window            Force a new instance of Code.
  -r, --reuse-window          Force opening a file or folder in the last active window.
  --user-data-dir <dir>       Specifies the directory that user data is kept in, useful when running as root.
  --verbose                   Print verbose output (implies --wait).
  -w, --wait                  Wait for the window to be closed before returning.
  --list-extensions           List the installed extensions.
  --install-extension <ext>   Installs an extension.
  --uninstall-extension <ext> Uninstalls an extension.
  -v, --version               Print version.
  -h, --help                  Print usage.

~/dev/Microsoft/vscode @master
❯ code-insiders -h 1> output

~/dev/Microsoft/vscode @master ?
❯ cat output 
Visual Studio Code v1.4.0-insider


Usage: code [arguments] [paths...]

Options:
  -d, --diff                  Open a diff editor. Requires to pass two file
                              paths as arguments.
  --disable-extensions        Disable all installed extensions.
  -g, --goto                  Open the file at path at the line and column (add
                              :line[:column] to path).
  --locale <locale>           The locale to use (e.g. en-US or zh-TW).
  -n, --new-window            Force a new instance of Code.
  -r, --reuse-window          Force opening a file or folder in the last active
                              window.
  --user-data-dir <dir>       Specifies the directory that user data is kept
                              in, useful when running as root.
  --verbose                   Print verbose output (implies --wait).
  -w, --wait                  Wait for the window to be closed before
                              returning.
  --list-extensions           List the installed extensions.
  --install-extension <ext>   Installs an extension.
  --uninstall-extension <ext> Uninstalls an extension.
  -v, --version               Print version.
  -h, --help                  Print usage.

@Tyriar Tyriar added info-needed Issue requires more information from poster windows VS Code on Windows issues labels Jul 11, 2016
@Tyriar
Copy link
Member

Tyriar commented Jul 11, 2016

Perhaps this is related to code.sh or code.cmd here? PRs welcome if that is the case.

@Tyriar Tyriar added the help wanted Issues identified as good community contribution opportunities label Jul 11, 2016
@bdchauvette
Copy link

This seems to be a problem with electron rather than VSCode specifically. See e.g. electron/electron#683 and electron/electron#4552

The workaround I'm using is to set the ELECTRON_NO_ATTACH_CONSOLE environment variable inside of the node process before spawning any instances of code:

process.env.ELECTRON_NO_ATTACH_CONSOLE = true;

const { execSync } = require('child_process');

const installedExtensions = execSync('code --list-extensions')
  .toString()
  .split('\n')
  .filter(Boolean);

// outputs an array
console.log(installedExtensions);

@espresso3389
Copy link

It seems that the current stable version, 1.7.2 works correctly. I think we can close the issue now.

Version 1.7.2
Commit 7ba55c5860b152d999dda59393ca3ebeb1b5c85f
Date 2016-11-21T22:06:37.428Z
Shell 1.3.8
Renderer 52.0.2743.82
Node 6.5.0

@Tyriar
Copy link
Member

Tyriar commented Dec 8, 2016

I guess it was fixed upstream at some point then, thanks for letting me know @espresso3389.

@Tyriar Tyriar closed this as completed Dec 8, 2016
@Tyriar Tyriar added this to the October 2016 milestone Dec 8, 2016
@aeschli aeschli added the verified Verification succeeded label Dec 9, 2016
@aeschli
Copy link
Contributor

aeschli commented Dec 9, 2016

Verified on Windows 10.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
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 help wanted Issues identified as good community contribution opportunities info-needed Issue requires more information from poster verified Verification succeeded windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests

6 participants