cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.76k stars 176 forks source link

VSCode 1.7 HISTFILE conflict #273

Open gzheng92 opened 1 year ago

gzheng92 commented 1 year ago

In the latest release version of VSCode, starting a terminal produces the following console output:

McFly: /var/folders/n6/k33n7qp50tsblm9wl5zqzvlr0000gn/T/vscode-zsh/.zsh_history does not exist or is not readable. Please fix this or set HISTFILE to something else before using McFly.

I tried adding

default_histfile="${HISTFILE:-$HOME/.zsh_history}"
export MCFLY_HISTFILE="${MCFLY_HISTFILE:-$default_histfile}"

to my ~/.zshrc, but that didn't help

Tarpstone commented 1 year ago

Looks like this is the new VSCode setting that causes the issue: terminal.integrated.shellIntegration.enabled. Turning it off and starting a new shell resulted in no more error for me.

Screen Shot 2022-08-08 at 22 32 01
gzheng92 commented 1 year ago

Hopefully the injection script used by VSCode will eventually work with mcfly, but I guess this is a good enough solution

daxmc99 commented 1 year ago

Manual shell integration (https://code.visualstudio.com/docs/terminal/shell-integration#_manual-installation) did not print this error for me. I was able to use the shell integration and McFly

emptymalei commented 1 year ago

Looks like this is the new VSCode setting that causes the issue: terminal.integrated.shellIntegration.enabled. Turning it off and starting a new shell resulted in no more error for me.

Screen Shot 2022-08-08 at 22 32 01

Thank you @Tarpstone This solved several problems for me, from poetry to pyenv, and of course mcfly.

cantino commented 1 year ago

Re-opening so it's easier for folks to find this issue. I wonder if there's anything mcfly's init script can do to fix this.

cantino commented 1 year ago

The claim is that this will be fixed in the next VSCode release: https://github.com/microsoft/vscode/issues/145296#issuecomment-1222465601

gzheng92 commented 1 year ago

I just updated and it is still not fixed, unable to comment on microsoft/vscode#145296 to let them know

cantino commented 1 year ago

Darn! I guess you could make a new issue.

pickx commented 1 year ago

For whatever reason, the manual installation for shell integration is unable to set theHISTFILE, so I just set it manually.

Just put this in your .zshrc: [[ "$TERM_PROGRAM" == "vscode" ]] && . "$(codium --locate-shell-integration-path zsh)" && HISTFILE=$USER_ZDOTDIR/.zsh_history

cantino commented 1 year ago

Is HISTFILE not set in the vscode shell by default?

PanadeEdu commented 1 year ago

Ran into the same issue today. I can confirm that removing the shell integration feature seems to work.

For whatever reason, the manual installation for shell integration is unable to set theHISTFILE, so I just set it manually.

Just put this in your .zshrc: [[ "$TERM_PROGRAM" == "vscode" ]] && . "$(codium --locate-shell-integration-path zsh)" && HISTFILE=$USER_ZDOTDIR/.zsh_history

btw.: this only works with the editor codium as I see it rn.

johndutchover commented 1 year ago

Ran into the same issue today. I can confirm that removing the shell integration feature seems to work.

For whatever reason, the manual installation for shell integration is unable to set theHISTFILE, so I just set it manually. Just put this in your .zshrc: [[ "$TERM_PROGRAM" == "vscode" ]] && . "$(codium --locate-shell-integration-path zsh)" && HISTFILE=$USER_ZDOTDIR/.zsh_history

btw.: this only works with the editor codium as I see it rn.

I substituted code for codium for my installation:

Version: 1.73.0 Commit: 8fa188b2b301d36553cbc9ce1b0a146ccb93351f Date: 2022-11-01T15:33:40.745Z Electron: 19.0.17 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Darwin arm64 22.1.0 Sandboxed: No

tisba commented 1 year ago

Looks like it is still not fixed in VSCode, see e.g. https://github.com/microsoft/vscode/issues/164025

I'm still seeing this (/cc @Tyriar):

Version: 1.73.1
Commit: 6261075646f055b99068d3688932416f2346dd3b
Date: 2022-11-09T02:22:48.959Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 22.1.0
Sandboxed: No
kevinquillen commented 1 year ago

Getting this error on a brand new machine, no VSCode, regular Terminal in Fedora 37.