This is my first question on SO, so I hope it's ok that I'm doing this. I have now had this problem twice and pulled my hair out searching for an answer. I found it the first time, and then forgot what the solution was. Now that I have worked it out again I wanted to make sure other people don't struggle with it because it's really simple in the end.
All I'm trying to do is make a new Jekyll site, which I've done tons of times before. It's all fine until I try to bundle anything, and then I get the error in the title of this question. I'm on macOS Sierra, and have updated it from El Capitain since last using Jekyll. Same last time, on my other computer.
Running gem install ffi -v '1.9.21'
gives the following error:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.21/COPYING
I'm not sure whether to give the answer here or let somebody else answer it. I just want to be able to find this question next time I forget and try every other ffi-related thing on the internet!