<p>I have a problem with switching context in a terminal and Docker desktop bar panel on Mac:</p>

<pre><code>kubectl config use-context master-cluster
error: open /Users/sacherus/.kube/config.lock: file exists

ls -lh /Users/sacherus/.kube/config.lock
----------  1 sacherus  staff     0B Jun  9 00:01 
</code></pre>

<p>I think it could be: Pycharm's kubernetes plugin, Docker desktop bar panel or some plugin to zsh. </p>

<p>Of course, I can delete config.lock, but this file is being created every few hours.</p>

sacherus
<p>Community wiki answer based on discussion from the comments</p>
<p>Most probably the root cause is duplicate entries in KUBECONFIG env.</p>
<p>To fix the problem export proper KUBECONFIG. This was also discussed <a href="https://stackoverflow.com/questions/58985141/getting-kubectl-config-use-context-error-when-trying-to-switch-context">here</a></p>
