Ruby on Rails: permission denied when using "rails generate controller welcome"

It needs ownership to write the re-write the pid for each server start.

I had to run it with my full local path & sudo

$ sudo chmod -R 777 /Users/MyName/Desktop/projects/my_project/tmp/


I solved that problem by running

sudo chmod -R 1777 /tmp

hope this helps other people like me who would prefer not having to deactivate the spring gem


I took a look at the library that's trying to write the pid file, lib/spring/env.rb.

The function in question tries to create a temporary directory at the same location each time unless the XDG_RUNTIME_DIR is set:

path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring"))

Setting said variable to a unique directory does the trick for me:

export XDG_RUNTIME_DIR=/tmp/`whoami`