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

Debug command with runtimeVersion not waiting for terminal load #177685

Closed
SiarheiBokuts opened this issue Mar 20, 2023 · 3 comments
Closed

Debug command with runtimeVersion not waiting for terminal load #177685

SiarheiBokuts opened this issue Mar 20, 2023 · 3 comments
Assignees
Labels
*out-of-scope Posted issue is not in scope of VS Code

Comments

@SiarheiBokuts
Copy link

SiarheiBokuts commented Mar 20, 2023

  • VS Code Version: 1.76.2 (latest)
  • OS Version: MAC OS 13.2.1 (Ventura)

Steps to Reproduce:

  1. add vscode launch command
{
      "type": "node",
      "request": "launch",
      "name": "Test",
      "runtimeVersion": "18",
      "program": "${workspaceFolder}/node_modules/.bin/jest",
      "console": "integratedTerminal",
    },
  1. also I use zsh with oh-my-szh
  2. inside .zshrc I autoset node version using nvm preload script
# Auto load .nvmrc file
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
  local node_version="$(nvm version)"
  local nvmrc_path="$(nvm_find_nvmrc)"

  if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
      nvm install
    elif [ "$nvmrc_node_version" != "$node_version" ]; then
      nvm use
    fi
  elif [ "$node_version" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default
  fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc 

it works fine and each time when I open projects it's auto load node version

image

Error

but when I run Test debug command using integratedTerminal it is somehow not waiting until the terminal is loaded. so it mixed the script code with nvm switching info
image

It just can't start the debugger =(

How it works

When I run debug command without "console": "integratedTerminal", then it works.

Also, it works if I comment preload nvm script inside .zshrc (doesn't looks like a good solution)

Looks like debug command can't wait until zsh finishes hooks and I guess we should somehow fix it

@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.76.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@roblourens
Copy link
Member

I would have expected that the echo is not actually interfering with the input, even if it looks like the next is messed up in the terminal

However you say

Also, it works if I comment preload nvm script inside .zshrc (doesn't looks like a good solution)

So there is probably something going on.

I think there is also still an open issue about a character limit when sending lots of text into the terminal, that we bump into sometimes when debugging in the terminal with a very long command, and maybe that is in play here as well.

@Tyriar
Copy link
Member

Tyriar commented Mar 27, 2023

I also wouldn't expect the echo to cause any problems, my guess is nvm is swallowing some input. Currently for new terminals they are given 1 second to initialize so you could maybe speed up start up to get it to work again? Though my experience with nvm is it's really slow.

I don't think there is anything we can do apart from debug to use some shell integration hooks for when the shell is initialized, that's a bigger feature though and depends #145234

@Tyriar Tyriar closed this as completed Mar 27, 2023
@Tyriar Tyriar added the *out-of-scope Posted issue is not in scope of VS Code label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

5 participants