If I don't use sudo, truffle compile
gives me an error: truffle compile
output.
With sudo there is no error: sudo truffle compile
output.
Why does that happen?
If I don't use sudo, truffle compile
gives me an error: truffle compile
output.
With sudo there is no error: sudo truffle compile
output.
Why does that happen?
This is caused by wrong permissions on some of Truffle's files/dirs in your system. They're probably owned by root and Truffle cannot write there. Simply removing the configuration should fix the issue:
Alternatively you might use
chown
to change ownership of those files but if you never modified the config manually just removing it is simpler and Truffle will recreate it for you and also redownload the compiler binaries when needed.This was recently reported by many users in Can't compile solc version "^0.8.9" #4431 but does not really seem to be a bug in Truffle itself. Not sure why it was so widespread - is some popular tutorial telling people to run Truffle with
sudo
or something? If you do, Truffle will create some files as root and won't be able to overwrite them or create new ones unless you keep running it withsudo
.