asdf-dart
asdf-dart copied to clipboard
Adding version watcher script to .zshrc causes VS Code shell environment to time out
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.
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 :disappointed:. 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 orps 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 :grimacing:
Hope that helps!
This didn't fix the issue. VS Code is still pausing on startup and freezing the terminal.
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 "<PID> exit 1" message.
The command in your rc file should look like: bash ${HOME}/.asdf/plugins/dart/tools/dart_version_watcher.sh &
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.
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
.