fish-ssh-agent icon indicating copy to clipboard operation
fish-ssh-agent copied to clipboard

(Re)starting multiple terminal windows race condition

Open jerr0328 opened this issue 2 years ago • 0 comments

I've noticed that when I restart my computer and have the terminal windows restored (I have multiple terminals in iTerm and some in VSCode), I start getting errors like:

fish: Unknown command: nv
~/.ssh/environment (line 4):
nv SSH_AGENT_PID 1013;
^
from sourcing file ~/.ssh/environment
	called on line 3 of file ~/.config/fish/functions/__ssh_agent_is_started.fish
in function '__ssh_agent_is_started'
	called on line 5 of file ~/.config/fish/conf.d/fish-ssh-agent.fish
from sourcing file ~/.config/fish/conf.d/fish-ssh-agent.fish
	called on line 246 of file /opt/homebrew/Cellar/fish/3.5.1/share/fish/config.fish
from sourcing file /opt/homebrew/Cellar/fish/3.5.1/share/fish/config.fish
	called during startup

My ~/.ssh/environment file looks like:

setenv SSH_AUTH_SOCK /tmp/ssh-xo1lUD2fkYK4/agent.1003;
setenv SSH_AGENT_PID 1017;
#echo Agent pid 1017;
nv SSH_AGENT_PID 1013;
#echo Agent pid 1013;

It seems then that multiple terminals are starting up the ssh agent at the same time and trying to write to the same lock file. I can also confirm I do have two SSH agents running:

 1013   ??  Ss     0:00.01 ssh-agent -c
 1017   ??  Ss     0:00.00 ssh-agent -c

jerr0328 avatar Nov 21 '22 07:11 jerr0328