microsoft / vscode

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

After updating to version 1.89 my $HOME path is incorrect. And not able to change it. #212508

Open AshfaqueAlam opened 6 months ago

AshfaqueAlam commented 6 months ago

Type: Bug

After updating to the version 1.89 of vscode my $HOME path is incorrect everytime for git bash on windows OS, the value should be C:\Users\USERNAME, but it shows, C:\UsersSERNAME kindly help.

VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:13:33.891Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz (8 x 1382)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.75GB (4.76GB free)| |Process Argv|--crash-reporter-id 868b5f13-d082-4ae8-a5d9-f1ae3f3b68e6| |Screen Reader|no| |VM|0%|
Extensions (42) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.2 vscode-sql-formatter|adp|1.4.4 Bookmarks|ale|13.5.0 project-manager|ale|12.8.0 vscode-sqlite|ale|0.14.1 preview-pdf|ana|1.0.0 vscode-django|bat|1.15.0 Bito|Bit|1.3.2 path-intellisense|chr|2.8.5 codeium|Cod|1.8.36 dscodegpt|Dan|3.2.11 python-preview|don|0.0.4 gitlens|eam|14.9.1 EditorConfig|Edi|0.16.4 auto-rename-tag|for|0.1.10 code-runner|for|0.12.2 vsc-python-indent|Kev|1.18.0 git-graph|mhu|1.30.0 vscode-docker|ms-|1.29.1 debugpy|ms-|2024.6.0 isort|ms-|2023.10.1 python|ms-|2024.6.0 vscode-pylance|ms-|2024.5.1 jupyter|ms-|2024.4.0 jupyter-keymap|ms-|1.1.2 vscode-jupyter-cell-tags|ms-|0.1.9 vscode-jupyter-slideshow|ms-|0.1.6 remote-containers|ms-|0.362.0 remote-ssh|ms-|0.110.1 remote-ssh-edit|ms-|0.86.0 makefile-tools|ms-|0.9.10 remote-explorer|ms-|0.4.3 material-icon-theme|PKi|5.2.0 vscode-thunder-client|ran|2.22.1 vscode-yaml|red|1.14.0 LiveServer|rit|5.7.9 vscode-djaneiro|the|1.4.2 errorlens|use|3.17.0 intellicode-api-usage-examples|Vis|0.2.8 vscodeintellicode|Vis|1.3.1 vscode-todo-highlight|way|1.0.5 vscode-import-cost|wix|3.3.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 tftest:31042121 vswsl492cf:30256860 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 da93g388:31013173 pythoncenvptcf:31043158 fchga941:31038042 dvdeprecationcf:31040882 dwnewjupytercf:31039676 ```
TylerLeonhardt commented 5 months ago

@meganrogge @Tyriar maybe shell integration related?

meganrogge commented 5 months ago

maybe yeah, does disabling terminal.integrated.shellIntegration.enabled fix it? @AshfaqueAlam

vaahtokarkki commented 5 months ago

For me with version 1.89.1 shell integration changes $HOME from /c/Users/<username> to C:\Users\<username>. I don't know if the shell default working directory is related to this, but after 1.89 update with shell integration enabled, default working dir is C:/Users/<user>/AppData/Local/Programs/Microsoft VS Code instead of project directory. Without shell integration it defaults to project directory.

cmcnicoll commented 5 months ago

I'm seeing similar behavior on 1.89.1:

  1. shellIntegration on
    • $HOME = C:\Users
    • Default working directory = C:/Users/<user>/AppData/Local/Programs/Microsoft VS Code
      • Edit: This is a display issue because when I ls, I see my project files.
  2. shellIntegration off
    • $HOME = /c/Users/<user>
    • Default working directory = project directory
takkasila commented 5 months ago

I have a similar problem, not exactly the same, but I found that it happens when shellIntegration-bash.sh is trying to pass a username that begins with a character 't', or 'n'. In my case my username is 'takka', so when it tries to pass the HOME=C\x3a\Users\takka the \t gets converted to a tab instead and the final result became C:\Users akka. Which in my case resulting in unable to find a gitconfig path and so on.

My quick fix is to add a check and string replacement after this line https://github.com/microsoft/vscode/blob/f209ce35ef894bd32c12057724e8d1f1139c433f/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh#L53

to

VALUE="$(echo -e "$ITEM" | cut -d "=" -f 2-)"
# Fix bug combination with escape character
if [[ "$VARNAME" == "HOME" ]]; then
    VALUE="$(echo -e "$ITEM" | cut -d "=" -f 2- | sed "s/\t/\/t/g")"
fi

If this is unrelated and should be a new issue or is duplicated then let me know.

hwf1324 commented 5 months ago

I'm seeing similar behavior on 1.89.1:

1. `shellIntegration` on

   * `$HOME` = `C:\Users`
   * Default working directory = `C:/Users/<user>/AppData/Local/Programs/Microsoft VS Code`

     * Edit: This is a display issue because when I `ls`, I see my project files.

2. `shellIntegration` off

   * `$HOME` = `/c/Users/<user>`
   * Default working directory = project directory

One more point: When shellIntegration is on (default)

  1. Set terminal.integrated.defaultProfile.windows to Git Bash Every time you create a new Git Bash terminal Default working directory = C:/Users/<user>/AppData/Local/Programs/Microsoft VS Code
  2. When terminal.integrated.defaultProfile.windows is not Git Bash Every time you create a new Git Bash terminal Default working directory = project directory
caden-maxwell commented 4 months ago

One more point: When shellIntegration is on (default)

  1. Set terminal.integrated.defaultProfile.windows to Git Bash Every time you create a new Git Bash terminal Default working directory = C:/Users/<user>/AppData/Local/Programs/Microsoft VS Code
  2. When terminal.integrated.defaultProfile.windows is not Git Bash Every time you create a new Git Bash terminal Default working directory = project directory

I'm seeing this as well. What's more is that in scenario 1, it's not actually activating my venv even though it appears to be activated ((.venv) shows up above the prompt), for example:

(.venv)
xxxx@xxxxx MINGW64 /c/Users/myUser/AppData/Local/Programs/Microsoft VS Code (main)
$ deactivate
grep: /c/Users/myUser/.vscode/extensions/ms-python.python-2024.9.11661012/python_files/deactivate/bash/envVars.txt: No such file or directory
grep: /c/Users/myUser/.vscode/extensions/ms-python.python-2024.9.11661012/python_files/deactivate/bash/envVars.txt: No such file or directory
grep: /c/Users/myUser/.vscode/extensions/ms-python.python-2024.9.11661012/python_files/deactivate/bash/envVars.txt: No such file or directory
cdrini commented 1 month ago

I recently updated to the latest version 1.93.1 a few days ago, and randomly hit this issue today. Removing git bash as my default terminal and closing/opening vs code fixed it. Note I had to close/re-open, doing a reload didn't work.