Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding version watcher script to .zshrc causes VS Code shell environment to time out #17

Open
Abion47 opened this issue Apr 23, 2021 · 5 comments

Comments

@Abion47
Copy link

Abion47 commented Apr 23, 2021

I have the following line at the bottom of my .zshrc file:

bash ${HOME}/.asdf/plugins/dart/tools/dart_version_watcher.sh

I didn't notice a problem for a while (due to my penchant to not close VS Code windows very often), but when starting up VS Code after a computer reboot, the shell environment took a while to initialize, after which I got a message saying "Unable to resolve your shell environment in a reasonable time. Please review your shell configuration." After that point, the integrated terminal was frozen on "Starting" no matter what I did. After some investigation, I narrowed the cause down to the above command.

Note that this only happens when VS Code is first starting up. If I comment that line and start up VS Code, then uncomment the line and refresh the integrated terminal with the zsh command, the terminal successfully refreshes.

@PatOConnor43
Copy link
Owner

Hi @Abion47 thanks for the report. Sorry for the delay, I was taking some time off.

Yeah I believe I've noticed some race conditions with the script as well where multiple watchers get started. I'm unsure if this is what is hanging up your terminal but I did put up this PR that I think should fix that issue #18 .

I have tried reproducing your issue specifically and I haven't had much luck 😞. Can you try checking out the branch for that PR and testing? You'll need to:

  • navigate to $HOME/.asdf/plugins/dart
  • git checkout fix-file-watcher
  • kill any remaining filewatcher processes (either killall fswatch if nothing else is using it or ps ax | grep fswatch and find the pids that are watching $HOME/.tool-versions and kill those.)
  • Then open up VS Code and see if your terminal works.

If you don't get back to me I'll probably just merge this because it works on my machine 😬

Hope that helps!

@Abion47
Copy link
Author

Abion47 commented May 2, 2021

This didn't fix the issue. VS Code is still pausing on startup and freezing the terminal.

@PatOConnor43
Copy link
Owner

Interesting. The script shouldn't block because I believe it should start a separate child processes for fswatch and the "event handler" for fswatch. You may want to try running this script in the background though. You can do that by adding an & to the end of the line. That will print to the shell when the script exits though (which is expected if you already have the fswatch running).

If this works I'll try to find a way to mute that " exit 1" message.

The command in your rc file should look like: bash ${HOME}/.asdf/plugins/dart/tools/dart_version_watcher.sh &

@PatOConnor43
Copy link
Owner

Okay I may have also found another issue.

Instead of using bash ${HOME}/.asdf/plugins/dart/tools/dart_version_watcher.sh can you remove the bash so it just looks like this? ${HOME}/.asdf/plugins/dart/tools/dart_version_watcher.sh

I don't think the pidof command is able to correctly find script if you run it with bash explicitly.

@Abion47
Copy link
Author

Abion47 commented May 3, 2021

So a couple of issues.

First, the pidof command is not installed on Mac by default it seems. I had to run brew install pidof to get the new script to run.

Second, after installing pidof, the script is complaining about illegal option -- o.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants