microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.23k stars 28.56k forks source link

Windows: Code opening cli.js when run as Administrator #91613

Open zikhan opened 4 years ago

zikhan commented 4 years ago

Steps to Reproduce:

  1. Open pwsh in windows terminal
  2. Go to any folder
  3. Run code . in the folder

Does this issue occur when all extensions are disabled?: Yes

Troubleshooting steps: Uninstalled and Reinstalled VSCode. <= This actually fixed the issue on another computer, but not my main work computer. Followed any other steps in #69373, #88432, #89088

The reason you don't see the wait in the terminal for the first 3 code . commands is because there was already a vscode window open, however, the cli.js was still opening in these instances. The terminal wait logging came back after closing all vscode instances. image

Nobody else got you the command line for the process, so here it is with some privacy censors. Some of the processes had really, really log command line args so I couldn't get them all to fit in my Task Manager window.... image

arthur404dev commented 4 years ago

The cli.js keeps opening up over and over. Even with VSCode closed.

It's also happening when writing code, which is making not viable to use VSCode.

I've seen 3 threads opened with the same description lately and all of those are being closed with the justification that not enough info given.

Somebody even posted a video of the occurence... Come on guys...

arthur404dev commented 4 years ago

image

This is the printscreen from ProcessHacker

joaomoreno commented 4 years ago

@zikhan Can you show me your %PATH% variable?

zikhan commented 4 years ago

user.name is my Windows user name

C:\Windows\System32
C:\Windows
C:\Windows\System32\wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\ProgramData\chocolatey\bin
C:\Program Files (x86)\GnuPG\bin
C:\Program Files\dotnet\
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\
C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\
C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE
C:\Program Files (x86)\GnuWin32\bin
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Go\bin
C:\Program Files\Intel\WiFi\bin\
C:\Program Files\Common Files\Intel\WirelessCommon\
C:\Program Files\Amazon\AWSCLI\bin\
C:\Program Files\nodejs\
C:\Program Files\PowerShell\6\
C:\Program Files\Docker\Docker\resources\bin
C:\ProgramData\DockerDesktop\version-bin
C:\Program Files\Git\cmd
C:\Users\user.name\AppData\Local\Microsoft\WindowsApps
C:\Users\user.name\.dotnet\tools
C:\Users\user.name\AppData\Local\Microsoft\WindowsApps
C:\Users\user.name\go\bin
C:\Program Files (x86)\Nmap
C:\Users\user.name\AppData\Roaming\npm
C:\Users\user.name\Documents\PowerShell\Scripts
C:\Users\user.name\AppData\Local\Programs\Microsoft VS Code\bin
zikhan commented 4 years ago

More useful information: image image

arthur404dev commented 4 years ago

image

I managed to capture the command lines for the process also.

If that's of any help.

The cli.js file itself is opening with the following:

"C:\Users\Arthur\AppData\Local\Programs\Microsoft VS Code\Code.exe" "C:\Users\Arthur\AppData\Local\Programs\Microsoft VS Code\bin\..\resources\app\out\cli.js" --list-extensions

joaomoreno commented 4 years ago

@zikhan Can you reproduce in a regular Command Prompt?

zikhan commented 4 years ago

yep image

Directory commented 4 years ago

im experiencing the same issue. it just randomly opens when im using the ide. thats it. doesnt matter what im doing. the tab just opens. any followup? I will note that i noticed the issue appear after i installed the Darkula Pycharm Theme although i can not for certain confirm it is the cause of the issue.

Update: its gotten so bad, the ide opens on its own. i didnt even have the application open and it did it itself wtf.

arthur404dev commented 4 years ago

@Directory

I tried all possible fixes without success, and as nobody from the vscode team provide a proper workaround i just installed the insider version, changed the .cmd to code and i'm using it as it was the stable release of VSCODE.

Funny as it is, the trigger doesn't happen on the "unstable" version of the software.

I hope it keeps that way.

I imported all the extensions using the Settings Sync and am having zero issues right now.

Directory commented 4 years ago

i think i solved it. it happens when you set the code.exe as administrator in the comaptibility options. disabled it, reboot, no more cli.js.

at least for me.

s4m0r4m4 commented 4 years ago

@Directory you might be on to something here!

I was experiencing the same issue, and has VS code set to always run as administrator for all users.

Its important for me to run VS Code as administrator for various reasons, so the workaround of always opening VS code as administrator manually doesn't feel like a tenable solution.

Directory commented 4 years ago

yea vscode is important to run as admin for me too. for example i do everything in admin cmd like install pip packages. tried to install some libs via vscode terminal and it wouldn't work since its not an admin terminal. this is only a minor inconvenience. some other file write permissions too. it wont hinder me too much since my development purposes are just updating some code, pushing it, and then winscp'ing it to my server and restarting the scripts. rarely do i actually need to run my code on in the ide. still a stupid bug. hope this discovery helps the devs fix this repeatedly neglected issue.

so the workaround of always opening VS code as administrator manually doesn't feel like a tenable solution.

wait, are you saying that the issue does not occur when manualy opening vscode as admin? only when set in the compatibility property's?

eduardobrl commented 4 years ago

This problem is somehow related to kite, i closed Kited.exe process and the cli.js stopped running.

At least for me.

s4m0r4m4 commented 4 years ago

wait, are you saying that the issue does not occur when manualy opening vscode as admin? only when set in the compatibility property's?

Sorry for the delay, but yes, when I just open it as adminstrator manually (rather than setting it to always open as administrator), the issue does not occur for me.

fodurrr commented 4 years ago

This problem is somehow related to kite, i closed Kited.exe process and the cli.js stopped running.

At least for me.

Same for me

Directory commented 4 years ago

I do remember using kite so yes, this must be a bug in kite not a bug in vscode.

s4m0r4m4 commented 4 years ago

I don't have the Kite extension installed fyi

timothy-johnston commented 4 years ago

I also began experiencing this issue when I installed Kite. VSCode would open up cli.js while I was in the middle of editing other files. I uninstalled Kite and restarted my machine and the issue stopped happening.

jt-at commented 4 years ago

Exactly the same for me: It stopped when I unistalled Kite from the program files as well as from vsc-extensions.

yufongpeng commented 4 years ago

I've encountered the same issue when changing the Code.exe to run as administrator. However, if I change the setting in the file shortcut Visual Studio Code alternatively, this issue never happens again!

birgersp commented 3 years ago

I have the same problem as OP, and I don't have kite

karlind commented 3 years ago

I ran into a similar problem. I open sudo code in Windows WSL, it keeps open cli.js. After check the related script located in C:\Users\Username\AppData\Local\Programs\Microsoft VS Code\bin\code, I found it will use a env named WSL_DISTRO_NAME to determine if in wsl. If open code in sudo, WSL_DISTRO_NAME will not be available.

So use sudo -E code to keep environment variable rather than sudo code, or modify file /etc/sudoers and just append one line:

Defaults        env_keep += "WSL_DISTRO_NAME"
ABusyProgrammer commented 3 years ago

@karlind Thank you! Your solution helped me when I was trying to start code as a root user in WSL through ZSH.

jjavierdguezas commented 3 years ago

This started to happen to me recently, I don't have Kite installed I can reproduce what @vvkjndl posted and I have Docker Desktop

Steps to reproduce the issue:

  • Set code.exe compatibility options to always Run as Administrator.
  • Run below command:

C:\Windows\system32\cmd.exe /c code --list-extensions

  • Many other applications run this command in the background at launch, reproducing this issue every time. Docker Desktop is one of those.
pvettori commented 3 years ago

Same problem for me. I don't have Kite but Docker Desktop installed. Every time I open Docker Desktop, the file "cli.js" opens in VS Code (super annoying).

I now have Docker Desktop 3.5.2 (66501) and experiencing this issue since january 2021. I also have the VS Code Docker extension v1.14.0 installed (ms-azuretools.vscode-docker).

verndemille commented 3 years ago

Same problem for me. I don't have Kite but Docker Desktop installed. Every time I open Docker Desktop, the file "cli.js" opens in VS Code (super annoying).

I now have Docker Desktop 3.5.2 (66501) and experiencing this issue since january 2021. I also have the VS Code Docker extension v1.14.0 installed (ms-azuretools.vscode-docker).

This started happening after installing Docker Desktop for me as well.

fifsus commented 3 years ago

Same here, cli.js opens on every startup of Docker Desktop (also when the Docker Desktop is running and I click the small Docker icon in notification area of Win10 taskbar) and also when I try to edit C# scripts from Unity Editor on the first launch of VSC.

YvesHenri commented 3 years ago

Has anyone found a fix for this? This also happens to me on Docker Desktop launch. This is extremelly annoying. Welp!

willibrandon commented 3 years ago

The same thing happens when I launch Docker Desktop. Please fix.

gabriel-messas commented 3 years ago

I can confirm: When the vscode executable has been set to always open as administrator, it brings up the cli.js file. However, it has to keep being open as administrator for several reasons. Did anybody find why it happens? If so, we can simply disable it somehow. Thanks.

VIMHaos commented 3 years ago

Same problem reproduce by starting Docker Desktop, and ms-azuretools.vscode-docker@1.15.0 extension enabled

guilhermeamadowj commented 3 years ago

Same here with docker. I don't use Kite.

arthur404dev commented 3 years ago

I found by accident that Kite was the reason why this was happening. Didn't dove further into that but uninstalling it fixed it for me.

nprezive commented 3 years ago

Bumping. I have the same issue with docker.

wethreetrees commented 3 years ago

What did not work for me:

  1. Disable Docker extension

Name: Docker Id: ms-azuretools.vscode-docker Description: Makes it easy to create, manage, and debug containerized applications. Version: 1.16.0 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker

  1. Disable Remote Container extension

Name: Remote - Containers Id: ms-vscode-remote.remote-containers Description: Open any folder or repository inside a Docker container and take advantage of Visual Studio Code's full feature set. Version: 0.191.1 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers

  1. Quit Docker Desktop - v3.5.2 (66501)

What did work for me: https://github.com/microsoft/vscode/issues/72521#issuecomment-507343840

I think I figured out a fix for anyone else facing this problem. If you run the command prompt as administrator, this problem goes away. It's only an issue if you have VSCode set to run as admin, but the command prompt terminal is not running with admin permission.

If I have VSCode open and I open Docker Desktop, it will still open the cli.js file though. This seems to only happen when opening a Docker Desktop window.

edit: So right after I posted, I updated Docker Desktop to v3.6.0 (67351) and the issue seems to be resolved.

imFS commented 2 years ago

Can confirm. Same problem here, this was a headache because I had no idea why I was losing my environment variables that I had in my terminal. Hope there will be a fix; Problem: VSCode will open cli.js on startup and also lose/delete its environment variables. Not sure if its related to cli.js but its contents start like: ""use strict";delete process.env.VSCODE_CWD;".. How: If you have your vscode shortcut set as 'always run as admin' (from compatibility tab) and run the "code" from your terminal (in my case my terminal had admin. rights)

Removing the run as admin from the shortcut did fix the issue yes, but its not an good solution imo. It also fixed the issue where code was running within my console, now when I run the command "code" or "code ." it doesn't block the terminal or give output to the terminal.

leafpuddle commented 2 years ago

Same problem here. I'm running vscode 1.63.2. I do not have Docker Desktop or Kite installed. This is occurring when I attempt to open a cs file from Unity Editor. I can reproduce the issue by launching vscode from a terminal independent from Unity. Only extension currently installed is the official C# extension from Microsoft (v1.23.17). Disabling this extension does not correct the issue.

I can confirm that the issue goes away when not running vscode as admin, however this is not an acceptable fix. A complete removal of vscode from my system and a reinstall did not resolve. I'm willing to provide additional information upon request.

Wanted to throw my hat in the ring, hoping for a fix eventually.

Hecedu commented 2 years ago

Any updates on this? I see the issue has been open since Feb 26 2020, it's been 2 years!

Whitebrim commented 2 years ago

Bump, I'm tired closing cli.js every time. I can't disable running VSCode as Admin because of my build scripts, so this single workaround is useless for me.

GreenVenator commented 2 years ago

For me, a workaround for this issue is to call code from an admin/elevated console. The way you can continue to launch code.exe as an admin, but without being interrupted by cli,js.

jumper385 commented 2 years ago

Solved!

Make sure your VSCode desktop shortcut isn't running as administrator

vscode shortcut running as administrator

If you see this, you will ALWAYS get the administration popup warning AND cli.js pop up on bootup EVEN from the terminal (i.e. code . in terminal).

Once you disable by right clicking, going to properties and Compatibility, you'll find "Run this program as an administrator". TURN THIS OFF!!! image

After this, EVERYTHING SHOULD RUN SMOOTH 😎😎😎 Thanks to @imFS for the suggestion!

What did not work for me:

  1. Disable Docker extension

Name: Docker Id: ms-azuretools.vscode-docker Description: Makes it easy to create, manage, and debug containerized applications. Version: 1.16.0 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker

  1. Disable Remote Container extension

Name: Remote - Containers Id: ms-vscode-remote.remote-containers Description: Open any folder or repository inside a Docker container and take advantage of Visual Studio Code's full feature set. Version: 0.191.1 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers

  1. Quit Docker Desktop - v3.5.2 (66501)

What did work for me: #72521 (comment)

I think I figured out a fix for anyone else facing this problem. If you run the command prompt as administrator, this problem goes away. It's only an issue if you have VSCode set to run as admin, but the command prompt terminal is not running with admin permission.

If I have VSCode open and I open Docker Desktop, it will still open the cli.js file though. This seems to only happen when opening a Docker Desktop window.

edit: So right after I posted, I updated Docker Desktop to v3.6.0 (67351) and the issue seems to be resolved.

Whitebrim commented 2 years ago

@jumper385 this is not solved, my build task must be executed with administrator right, so I have to run VSCode as admin. This is the first app that breaks if you grant it admin rights...

khasmir04 commented 2 years ago

Using unity for development here and this issue also occurs, hope this gets solved :/

Whitebrim commented 2 years ago

@khasmir04 VisualStudio 2022 is better for Unity, it has AI code autocompletion

khasmir04 commented 2 years ago

@Whitebrim thanks, but I mainly work on web development so kinda used to vsc, I'm working on a small project for now so vsc is suffice and tbh my system gets laggy using vs but thanks, will switch to vs once system gets upgraded and decided to pursue more in unity 👍🏼

DuzaBF commented 2 years ago

I have a similar problem when developing with nRF Connect for Desktop. I have to run the VS Code as Administrator, so I turned the "Run this program as an administrator" on. If I open the Toolchain Manager from nRF Connect for Desktop as normal user it opens the VSCode with cli.js right away and also opens cli.js when I click "Open VS Code". If I run nRF Connect for Desktop as Administrator then I have no problems with cli.js.

wanzhiyu commented 2 years ago

@Directory you might be on to something here!

I was experiencing the same issue, and has VS code set to always run as administrator for all users.

  • I changed Code.exe to not run as administrator and the issue stopped. With that same setting, I opened Code as administrator and the issue still did not occur.
  • I changed Code.exe back to run as administrator for all users again, and the issue began occurring again!
  • I changed Code.exe to run as administrator just for me (not all users), and the issue occured.
  • Just in case it's useful, I'll also note that I observed this behavior (VS code trying to open cli.js) repeatedly when trying to open Anaconda navigator.

Its important for me to run VS Code as administrator for various reasons, so the workaround of always opening VS code as administrator manually doesn't feel like a tenable solution.

I'm sure it is the problem created by Anaconda navigator. I never countered this problem until I opened Anaconda navigator today and something popped up and I closed it.

Ikhari commented 1 year ago

bruh still no fix for this ?😭

tdbe commented 1 year ago

Bruh 🙂 We've had this cli tab vscode problem since well before covid. And it's still happening to this day. So it's been what, 30 years and no fix or explanation?