You are most likely running into issues because you are uploading or processing things as a different user from the one Apache (or nginx/php) runs as. PHP can't write those files because of the differing user and file permissions, and so you get the errors.
If you're doing anything as root
, fix that first. Don't.
Otherwise, you might try putting your user and the Apache user in the same group, and setting that group on all Magento files and directories.
See here for recommended permissions setup in Magento 2.x:
if running as root:
su USER -s /bin/bash -c "MAGENTO COMMAND"
to change the owner:
chown -R user:user *