I was getting this error,
This solution worked, but the error occured again after closing my terminal and reopening it; I had to run the same commands every time I opened a new terminal window.
I found a suggestion here which indicated,
as the fix. However, this threw an error that the developer path was invalid.
Instead, for me, I modified this to,
(which is a mixture of the two referenced solutions) and everything worked as expected!