microsoft / vscode

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

Terminal (still) launching with incorrect working directory #190927

Closed lobsterkatie closed 1 year ago

lobsterkatie commented 1 year ago

Type: Bug

This is a follow-up to https://github.com/microsoft/vscode/issues/133542, to report that (sadly) this is still happening.

TL;DR: A VSCode window opens, and restores the contents of the terminal... except it's the contents of the ternimal from a different window.

@Tyriar did some really impressive investigation to track down the cause, (I'm not just saying that to curry favor to get you to fix this more quickly - I really was impressed!) and a fix was implemented in https://github.com/microsoft/vscode/pull/186947, which was released in 1.81.

And yet. I am currently using 1.81, and just ran code dirA in the terminal running inside the workspace for dirB, and when the window for dirA opened, it restored the contents (and working directory) of dirC (which is currently open in a separate workspace/window).

(To make this more concrete, so it matches the screenshots, dirA is (ironically) my fork of VSCode itself, dirB is hackweek2023, and dirC is relay.)

I checked various places for any errors which might have shown up right when this happened (dev tools, various output channels) and only found anything relevant in the Pty Host logs. (Interestingly, they seem to be the identical logs in both the launcher window (hackweek2023) and the launchee window (vscode-fork), stretching back before either window was opened, all the way back to me launching VSCode this morning. This is a single, shared process across windows, then, I'm guessing?)

In any case, here are the logs:

PtyHost logs
2023-08-21 10:28:57.566 [info] Revived process, old id 690acd72a03bd9e210acdf6e36959217-2 -> new id 1
2023-08-21 10:28:57.587 [info] Revived process, old id e06c0c7856e35bba4431dabd025b6ea5-1 -> new id 2
2023-08-21 10:28:57.598 [info] Revived process, old id f3720914d92872475fc76e5b5cc34552-5 -> new id 3
2023-08-21 10:28:57.598 [info] Revived process, old id f3720914d92872475fc76e5b5cc34552-6 -> new id 4
2023-08-21 10:28:57.600 [info] Revived process, old id 6e9ada40beb7d23793eed290165cbd65-3 -> new id 5
2023-08-21 10:28:57.604 [info] Revived process, old id 7e3ae51eea0cbc99db974123641a11ce-4 -> new id 6
2023-08-21 10:28:59.390 [info] Expanding terminal instance, old id 7e3ae51eea0cbc99db974123641a11ce-4 -> new id 6
2023-08-21 10:29:00.512 [info] Expanding terminal instance, old id e06c0c7856e35bba4431dabd025b6ea5-1 -> new id 2
2023-08-21 10:29:00.551 [info] Expanding terminal instance, old id 690acd72a03bd9e210acdf6e36959217-2 -> new id 1
2023-08-21 10:29:01.013 [info] Expanding terminal instance, old id 6e9ada40beb7d23793eed290165cbd65-3 -> new id 5
2023-08-21 10:29:01.245 [info] Expanding terminal instance, old id f3720914d92872475fc76e5b5cc34552-5 -> new id 3
2023-08-21 10:29:01.245 [info] Expanding terminal instance, old id f3720914d92872475fc76e5b5cc34552-6 -> new id 4
2023-08-21 10:29:10.241 [warning] Persistent process "5": Process had no disconnect runners but was an orphan
2023-08-21 10:29:10.242 [info] Persistent process reconnection "5"
2023-08-21 10:29:10.819 [warning] Persistent process "1": Process had no disconnect runners but was an orphan
2023-08-21 10:29:10.819 [info] Persistent process reconnection "1"
2023-08-21 10:29:10.965 [warning] Persistent process "6": Process had no disconnect runners but was an orphan
2023-08-21 10:29:10.965 [info] Persistent process reconnection "6"
2023-08-21 10:29:11.105 [info] Persistent process "5": Replaying 4124 chars and 1 size events
2023-08-21 10:29:11.240 [warning] Persistent process "3": Process had no disconnect runners but was an orphan
2023-08-21 10:29:11.241 [info] Persistent process reconnection "3"
2023-08-21 10:29:11.243 [warning] Persistent process "4": Process had no disconnect runners but was an orphan
2023-08-21 10:29:11.243 [info] Persistent process reconnection "4"
2023-08-21 10:29:11.269 [info] Persistent process "6": Replaying 1308 chars and 1 size events
2023-08-21 10:29:11.463 [info] Persistent process "3": Replaying 55717 chars and 1 size events
2023-08-21 10:29:12.345 [info] Persistent process "1": Replaying 2156 chars and 1 size events
2023-08-21 10:29:12.728 [info] Persistent process "4": Replaying 65499 chars and 1 size events
2023-08-21 10:29:12.985 [warning] Persistent process "2": Process had no disconnect runners but was an orphan
2023-08-21 10:29:13.000 [info] Persistent process reconnection "2"
2023-08-21 10:29:13.198 [info] Persistent process "2": Replaying 79543 chars and 1 size events
2023-08-21 15:55:48.470 [info] Revived process, old id 0d19288d05da5b4eeea4437a6e5b19e6-4 -> new id 16
2023-08-21 15:55:49.794 [info] Expanding terminal instance, old id 0d19288d05da5b4eeea4437a6e5b19e6-4 -> new id 16
2023-08-21 15:55:51.283 [warning] Persistent process "16": Process had no disconnect runners but was an orphan
2023-08-21 15:55:51.283 [info] Persistent process reconnection "16"
2023-08-21 15:55:51.792 [info] Persistent process "16": Replaying 72960 chars and 1 size events

If there's any other kind of logging I can enable (and just leave running until the next time this happens), please let me know. And thanks - I'm sure you're just as tired of this bug as I am!

VS Code version: Code 1.81.1 (Universal) (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:20:33.924Z) OS version: Darwin x64 22.6.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2600)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|7, 7, 10| |Memory (System)|32.00GB (0.32GB free)| |Process Argv|--crash-reporter-id b0279d3b-8393-4b25-b76f-67c5cd50b58e| |Screen Reader|yes| |VM|0%|
Extensions (70) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|13.4.1 separators|ale|2.5.0 tasks-shell-input|aug|1.8.2 shifty|bme|2.0.1 multi-cursor-case-preserve|Car|1.0.5 solargraph|cas|0.24.0 npm-intellisense|chr|1.4.4 path-intellisense|chr|2.8.4 bracket-select|chu|2.0.2 vscode-markdownlint|Dav|0.51.0 vscode-eslint|dba|2.4.2 vscode-npm-source|dku|1.0.0 githistory|don|0.6.20 typescript-notebook|don|2.0.6 nunjucks-vscode-extensionpack|dou|0.0.1 gitlens|eam|14.2.1 EditorConfig|Edi|0.16.4 prettier-vscode|esb|10.1.0 vscode-firefox-debug|fir|2.9.8 shell-format|fox|7.2.5 ghost-text|fre|1.4.0 remotehub|Git|0.60.0 vscode-github-actions|git|0.26.1 vscode-pull-request-github|Git|0.70.0 npm-dependency-links|her|1.2.0 background-terminal-notifier|jar|1.0.3 search-node-modules|jas|1.3.0 code-eol|jef|1.0.12 vscode-case-shifter|Jin|1.1.0 docthis|joe|0.7.1 vscode-peacock|joh|4.2.2 bracket-peek|jom|1.4.4 cornflakes-linter|kev|0.5.1 vsc-python-indent|Kev|1.18.0 yarn-lock-syntax|mar|0.2.0 template-string-converter|meg|0.6.1 xcodestrings|mhc|1.0.0 git-graph|mhu|1.30.0 dotenv|mik|1.0.1 playwright|ms-|1.0.15 black-formatter|ms-|2023.4.1 flake8|ms-|2023.6.0 isort|ms-|2023.10.1 mypy-type-checker|ms-|2023.2.0 python|ms-|2023.14.0 vscode-pylance|ms-|2023.8.30 makefile-tools|ms-|0.7.0 remote-repositories|ms-|0.38.1 test-adapter-converter|ms-|0.1.8 polacode|pnp|0.3.4 vscode-yaml|red|1.14.0 vscode-gitweblinks|red|2.9.2 vscode-sort-json|ric|1.20.0 synthwave-vscode|Rob|0.1.15 bash-debug|rog|0.3.9 rust-analyzer|rus|0.3.1631 crates|ser|0.6.0 gitconfig|sid|2.0.1 sonarlint-vscode|Son|3.20.2 rewrap|stk|1.16.3 even-better-toml|tam|0.19.2 vscode-mdx|uni|1.4.0 tab-groups|usa|2.1.1 errorlens|use|3.13.0 vscode-lldb|vad|1.9.2 vscodeintellicode|Vis|1.2.30 txt-syntax|xsh|0.2.2 vscode-mdx-preview|xyc|0.3.3 power-edit|YuT|1.3.0 vscode-open-in-github|ziy|1.3.6 (11 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 py29gd2263cf:30792227 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vsccc:30803844 282f8724:30602487 f6dab269:30613381 showlangstatbar:30737416 a2ce3375:30757347 pythonfmttext:30731395 pythoncmvfstrcf:30756944 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 gsofb:30804716 pythonnosmt12:30797651 pythonidxptcf:30805731 pythonnoceb:30805159 dsvsc013:30795093 dsvsc014:30804076 diffeditorv1:30812748 ```

Screenshots, showing the command I ran (and the working directory I was in when I ran it), the window which opened as a result, and the terminal whose contents were restored in that window:

image

image

Tyriar commented 1 year ago

😱

Tyriar commented 1 year ago

Luckily the logging situation is way better now. To get the most information you can temporarily enable trace logging by default:

image

Then the next time you hit it you should have trace logs which provide a lot more information.

The Pty Host (the process where the pty is hosted) and Terminal (the frontend browser window process) output channels are the relevant ones to this

lobsterkatie commented 1 year ago

Okay, I've set pty host and terminal to trace, and will let you know!

meganrogge commented 1 year ago

Let us know if you're still seeing this and have logs to help us investigate

lobsterkatie commented 11 months ago

I haven't seen it in a while, but I mostly only restart VSCode to get the new update every month, and I'll admit, I haven't been checking all my restored terminals when that happens - I'm generally too nerdily excited to dig into the release notes. 🤦🏻‍♀️

If you want to call this done, I'm happy to just keep watch and open a new issue (referencing this one) if it ever happens again.