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

Second window to open does not open folder when first's cwd is deleted #2259

Closed
martypdx opened this issue Jan 25, 2016 · 8 comments
Closed
Assignees
Labels
nodejs NodeJS support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream workbench-electron Electron-VS Code issues

Comments

@martypdx
Copy link

Version 0.10.6 (0.10.6) on OSX.

> mkdir test1 && cd test1
> code .
> cd ..
> rm -rf test1
> mkdir test2 && cd test2
> code .

Second instance hangs until you completely quit vs code and relaunch.

Why would anyone do this? I'm grading student assignments, so I git clone and then delete directory after reviewing each student's assignment.

@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Jan 26, 2016
@bpasero bpasero modified the milestone: Jan 2016 Jan 26, 2016
@bpasero
Copy link
Member

bpasero commented Jan 27, 2016

@martypdx this seems to be nodejs/node#1184

as a workaround, do not cd into the folder but instead open the folder from its parent directory.

@bpasero bpasero changed the title App hangs opening new vscode when existing vscode instance directory has been removed Fails to open second window when cwd is deleted Jan 27, 2016
@bpasero bpasero added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Jan 27, 2016
@bpasero bpasero modified the milestones: Backlog, Jan 2016 Jan 27, 2016
@martypdx
Copy link
Author

as a workaround, do not cd into the folder but instead open the folder from its parent director

good idea, thx!

@martypdx
Copy link
Author

martypdx commented Feb 5, 2016

Poking around some more on this, it seems that it only happens if the initial cwd that causes code to launch is deleted. It crashes even if the initial window is closed before deleting. (And inversely, subsequent opens don't bring down code if they are deleted).

So while there is an underlying node issue, it would seem code could be made more tolerant. I haven't dug into the src at all, but wouldn't it make more sense to have the root process process.chdir to someplace other than the initial code directory, and launch the initial window in the same manner as any other subsequent open request?

@bpasero
Copy link
Member

bpasero commented Feb 5, 2016

Where should Code chdir to? I am feeling uneasy doing such a change without understanding the impact for all spawned processes.

@martypdx
Copy link
Author

martypdx commented Feb 5, 2016

Where should Code chdir to? I am feeling uneasy doing such a change without understanding the impact for all spawned processes.

Well there's already an impact between the first opened directory and all subsequent spawned instances. I'm guessing the root process that spawns additional instances gets tied to the first directory from which code is launched. So perhaps it could chdir to the app dir or somewhere "safe" and then the first code editor instance would be spawned like any other instance it the original directory from which it was opened.

@bpasero
Copy link
Member

bpasero commented Feb 6, 2016

@martypdx I think you could already do this with the current release. If you look at the script on Mac to launch code you see that we define a CWD variable called VSCODE_CWD:

function code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*; }

If you hardcode that one to be some other directory, it should work.

@bpasero bpasero added electron Issues and items related to Electron and removed electron-update labels Mar 8, 2017
@bpasero bpasero added workbench and removed bug Issue identified by VS Code Team member as probable bug labels Apr 7, 2017
@bpasero bpasero added nodejs NodeJS support issues and removed workbench electron Issues and items related to Electron labels Nov 12, 2017
@bpasero bpasero removed this from the Backlog milestone Nov 16, 2017
@bpasero bpasero added the confirmed Issue has been confirmed by VS Code Team member label Jan 28, 2019
@bpasero bpasero added upstream-issue-linked This is an upstream issue that has been reported upstream and removed confirmed Issue has been confirmed by VS Code Team member labels Oct 14, 2019
@bpasero bpasero changed the title Fails to open second window when cwd is deleted Second window to open does not open folder when first's cwd is deleted Jan 13, 2020
@sguillia
Copy link

sguillia commented Jan 30, 2020

It seems I just had this problem. Unable to open a folder until I completely quit vscode and relaunch.

Version:

Version: 1.42.0-insider
Commit: be9c72410acc677070685a616773b122f4c5e141
Date: 2020-01-29T05:36:49.901Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 4.15.0-74-generic

I only deleted the .vscode folder that was created in the workspace.
After that, built-in extensions started crashing with this error message:

The TypeScript language service died 5 times right after it got started. The service will not be restarted

But the extension was restarted anyway (which is a bug in itself), so it kept crashing every few seconds.

Capture du 2020-01-30 14-43-36

@bpasero
Copy link
Member

bpasero commented Nov 4, 2020

Since this issue has a linked upstream issue referenced, I am going ahead to close this issue as part of our issue grooming effort: https://github.com/microsoft/vscode/wiki/Issue-Grooming

@bpasero bpasero closed this as completed Nov 4, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
nodejs NodeJS support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream workbench-electron Electron-VS Code issues
Projects
None yet
Development

No branches or pull requests

4 participants