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

Terminal Shell Integration Error -- command not found #157851

Closed
branic opened this issue Aug 10, 2022 · 6 comments · Fixed by #157945
Closed

Terminal Shell Integration Error -- command not found #157851

branic opened this issue Aug 10, 2022 · 6 comments · Fixed by #157945
Assignees
Labels
bug important new release terminal-shell-bash terminal-shell-integration unreleased
Milestone

Comments

@branic
Copy link

branic commented Aug 10, 2022

Type: Bug

After upgrading to 1.70.1 the integrated terminal (with shell integration enabled) is generating the following error whenever a terminal is launched and also after every command.

bash: [[ "$BASH_COMMAND" != "$PROMPT_COMMAND" ]] && chruby_auto: command not found...

This appears to be related to #157189 as the 1.70.1 version was the first to include the fix for that issue.

The error is the same as what trap -p DEBUG is set to. This seems like the command trying to be run is a string and is not being parsed like there are arguments.

$ trap -p DEBUG
trap -- '[[ "$BASH_COMMAND" != "$PROMPT_COMMAND" ]] && chruby_auto' DEBUG

VS Code version: Code 1.70.1 (6d9b74a, 2022-08-10T06:09:15.055Z)
OS version: Linux x64 5.18.15-200.fc36.x86_64
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz (12 x 2700)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 1
Memory (System) 62.56GB (3.04GB free)
Process Argv --unity-launch --crash-reporter-id 57fdd0a5-4103-4bed-9134-70c1dcd69cc9
Screen Reader no
VM 0%
DESKTOP_SESSION gnome-xorg
XDG_CURRENT_DESKTOP GNOME
XDG_SESSION_DESKTOP gnome-xorg
XDG_SESSION_TYPE x11
Extensions (38)
Extension Author (truncated) Version
asciidoctor-vscode asc 2.9.8
scratchpads bue 0.0.7
solargraph cas 0.23.0
vscode-markdownlint Dav 0.47.0
ansible-vault dho 0.1.3
docs-markdown doc 0.2.113
githistory don 0.6.19
gitlens eam 12.1.2
json-tools eri 1.0.2
opensslutils ffa 1.1.1
shell-format fox 7.2.2
gc-excelviewer Gra 4.2.55
todo-tree Gru 0.0.215
rest-client hum 0.25.0
vscode-jmespath jos 0.0.6
bash-ide-vscode mad 1.14.0
git-graph mhu 1.30.0
vscode-docker ms- 1.22.1
python ms- 2022.12.0
vscode-pylance ms- 2022.8.20
remote-containers ms- 0.241.3
remote-ssh ms- 0.84.0
remote-ssh-edit ms- 0.80.0
cpptools ms- 1.11.5
ruby reb 0.28.1
ansible red 0.11.29
vscode-commons red 0.0.6
vscode-yaml red 1.9.1
bash-debug rog 0.3.9
rufo-vscode sil 0.0.3
code-spell-checker str 2.5.4
shellcheck tim 0.19.6
pdf tom 1.2.0
vscode-icons vsc 11.15.0
vim vsc 1.23.2
jinja who 0.0.8
vscode-ruby win 0.28.0
markdown-all-in-one yzh 3.4.3

(2 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
wslgetstarted:30449410
cppdebug:30492333
vscaat:30438848
pylanb8912cf:30529770
vsclangdf:30486550
c4g48928:30535728
d7fjc500:30543455
dsvsc012cf:30540253

@VSCodeTriageBot VSCodeTriageBot added the new release label Aug 10, 2022
@matthewjdegarmo
Copy link

matthewjdegarmo commented Aug 11, 2022

Bump. I'm also getting this.

@Tyriar
Copy link
Member

Tyriar commented Aug 11, 2022

@meganrogge the fix for #157189 may not have worked for all cases?

@Tyriar Tyriar added bug terminal-shell-integration terminal-shell-bash labels Aug 11, 2022
@Tyriar Tyriar added this to the August 2022 milestone Aug 11, 2022
@Tyriar Tyriar added the important label Aug 11, 2022
@meganrogge
Copy link
Contributor

meganrogge commented Aug 11, 2022

Okay so we'll disable if there's an error

@branic
Copy link
Author

branic commented Aug 12, 2022

@meganrogge @Tyriar I've been looking into this a bit more and the pieces that were added are good, but they just don't go quite far enough. The replacements that were added leave the ' character in place at the beginning and end. Adjusting the line that strips the DEBUG to include the space before it and then adding lines to remove the ' allow the function to work as expected in my testing.

         if [[ "$__vsc_dbg_trap" =~ .*\[\[.* ]]; then
                 #HACK - is there a better way to do this?
                 __vsc_dbg_trap=${__vsc_dbg_trap#'trap -- '*}
                 __vsc_dbg_trap=${__vsc_dbg_trap%' DEBUG'}
                 __vsc_dbg_trap=${__vsc_dbg_trap#"'"*}
                 __vsc_dbg_trap=${__vsc_dbg_trap%"'"}
         else

Stripping the ' character could be done in the two commands, but I think adding two additional lines to strip is safer as it seems to me that it would be possible to have a trap without surrounding ', but that may not be the case.

@branic
Copy link
Author

branic commented Aug 12, 2022

A little bit more playing around and and even for single commands trap -p adds the ' characters.

For example setting the DEBUG trap to:

trap echo DEBUG

then trap -p DEBUG will return

trap -- 'echo' DEBUG

This means that this code block:

	__vsc_dbg_trap="$(trap -p DEBUG)"
	if [[ "$__vsc_dbg_trap" =~ .*\[\[.* ]]; then
		#HACK - is there a better way to do this?
		__vsc_dbg_trap=${__vsc_dbg_trap#'trap -- '*}
		__vsc_dbg_trap=${__vsc_dbg_trap%'DEBUG'}
	else
		__vsc_dbg_trap="$(trap -p DEBUG | cut -d' ' -f3 | tr -d \')"
	fi

could be simplified to

	__vsc_dbg_trap="$(trap -p DEBUG)"
	__vsc_dbg_trap=${__vsc_dbg_trap#"trap -- '"*}
	__vsc_dbg_trap=${__vsc_dbg_trap%" 'DEBUG"}

@branic
Copy link
Author

branic commented Aug 12, 2022

Based on the above comments, I don't think #157945 is the correct fix.

@Tyriar Tyriar removed their assignment Aug 12, 2022
@VSCodeTriageBot VSCodeTriageBot added the unreleased label Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug important new release terminal-shell-bash terminal-shell-integration unreleased
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants