vscode-rdbg: Attach mode does not work on version 0.2.1 using zsh
When using zsh as the login shell, attaching to a running instance of Rails using UNIX Socket fails with the following error:
connect ENOENT 1337;RemoteHost=<user>@<machine>.local 1337;CurrentDir=/Users/<user>/<repoDir> 1337;ShellIntegrationVersion=13;shell=zsh/var/folders/9v/<TempDir>/ruby-debug-sock-501/ruby-debug-<user>-7957
macOS 13.4 VSCode 1.78.2 rdbg 1.7.1 & 1.8.0 Ruby 2.7.8 Rails 6.0.6
It work fine in version 0.1.0. It got broken in version 0.2.0
It is possible to attach to the process using TCP/IP but no breakpoint will be hit. It is however possible to break on exception when connected in this manner on version 0.2.1.
As reported in this issue, there is no issue when using bash as the login shell on with version 0.2.1
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 46 (1 by maintainers)
Commits related to this issue
- Disable color outputs Closes ruby/vscode-rdbg#277 The problem is that we can't extract the result from stdout since Oh other zshell framework outputs many strings to stdout. To prevent it, we add TER... — committed to ono-max/vscode-rdbg by ono-max a year ago
- Disable color outputs Closes ruby/vscode-rdbg#277 The problem is that we can't extract the result from stdout since Oh other zshell framework outputs many strings to stdout. To prevent it, we add TER... — committed to ono-max/vscode-rdbg by ono-max a year ago
- Disable color outputs in zshell Closes ruby/vscode-rdbg#277 The problem is that we can't extract the result from stdout since Oh other zshell framework outputs many strings to stdout. To prevent it, ... — committed to ono-max/vscode-rdbg by ono-max a year ago
- Disable color outputs in zshell Closes ruby/vscode-rdbg#277 The problem is that we can't extract the result from stdout since Oh other zshell framework outputs many strings to stdout. To prevent it, ... — committed to ono-max/vscode-rdbg by ono-max a year ago
I apologize for any inconvenience, everyone. I will be discussing a solution to address these issues with the original author. Please bear with us a moment.
For anyone finding this thread, the issue for me was
fzf.A good way to avoid this problem is to define a special environment variable in
launch.json:Then, in
.zshrcskip initialization of plugins that invokezleHi guys, I have found a probably better way to fix this problem without having to touch the code of the extension or have to tell people to put their rbenv initialization routine in the login shell configuration file.
Wrap your shell integration initialization in the following condition:
This will prevent the shell integration from being loaded when the parent process is VSCode. This should probably also work with Oh My Zsh.
I encountered the same problem while playing with the TypeProf extension, so my guess is that this will be a very common occurence in the Ruby world.
I suggest you put something about this somewhere in the extension documentation so people can solve this easily.
HTH
What you say is true, but they mention this just after the ./zshrc setup in the pyenv documentation:
If you wish to get Pyenv in noninteractive login shells as well, also add the commands to ~/.zprofile or ~/.zlogin.What I don’t understand is why they don’t suggest putting this in the config file that is common to all shells. They might have some reason for doing so.
@miharekar is correct: If you load the content of
~/.zshrcyou will also load iTerm2 Shell Integration scripts. What could cause issues would be if rbenv requires something else from the~/.zshrcto be loaded beforehand.I am not quite sure to understand why rbenv decided to put its configuration in
~/.zshrcinstead of~/.zshenv. Clarifying these reasons might give you a better shot at fixing this issue long term. But I agree with @miharekar and what was said in the Oh My Zsh issue, I don’t see why it should require be run in either a login or interactive shell. Since I am new to Ruby, I may lack background information on the matter.Ideally we’d not load the terminal in the interactive mode.
Instead of coupling with iTerm, you could technically couple with rbenv/chruby since they’re both ruby managers and this is a ruby plugin. So instead of relying on interactive terminal to load them, you’d try to load them in the way they should be loaded from their respective readmes. Silently fail if you can’t load and give a way in settings to override the “smart ruby manager detection” mode.
@plfoley if I try your makeShellCommand on 0.2.1 I get same error and this in the terminal output:
But if I remove
test -e ${HOME}/.iterm2_shell_integration.zsh && source ${HOME}/.iterm2_shell_integration.zshfrom .zshrc it does indeed fix the issue!Is there a way to add an if rdbg around this iterm2 sourcing? That would fix the issue and can go into the readme of rdbg that it’s required for iterm2 users.Edit: This fixed it for me inside zshrc 🥳
All yours! Happy to see this fixed. One thing you could do to improve on my solution would be to test if the file ~/.iterm2_shell_integration.zsh exists. That would be a a sure-fire way of telling if iTerm2 Shell Integration was deployed but that would increase the coupling with their implementation a bit as well. It is your call at this point.
Have you folks tried configuring the new
"rdbg.rubyVersionManager"VS Code setting? That fixed a similar error on one of my machines.@miharekar @plfoley
Could you check the following steps?
$ rdbg target.rb --OI got the following results in my environment:
$ rdbg --util=list-socksin another windowI got the following results in my environment:
rdbg -A --sock-path=<socket path>I got the following results in my environment: