Running mix commands requires sudo

On a specific Phoenix project in my computer I cannot run any mix command unless I include sudo i.e mix phx.server or mix format I get this error

could not write to file "/home/mullah/projects/elixir/tundulisu/_build/dev/lib/tundulisu/.mix/compile.elixir": permission denied

So I have to do sudo mix phx.server . How can I fix this?

sudo rm _build deps
sudo chown -R $(id -ug):$(id -gn) .
mix do deps.get, deps.compile

Run this from your projects root. It will delete all artifacts and then repair permissions of your sources.

1 Like

gives id: cannot print "only" of more than one choice

Then fill in your users name and main group explicitely.

okay fine

it worked. thanks