Running `yarn` leads to write error

When I try to run yarn (install) in a terminal of a codespace, I get this error:

Error: EPERM: operation not permitted, chmod ‘/home/codespace/workspace/berry/.pnp.js’

whoami outputs codespace.

1 Like

Did you happen to install anything using “sudo”? If so, you can hit a situation where some files in your workspace are owned by root.

If you run ls -l from /home/codespace/workspace/berry, see if anything is owned by root.

If so, try running sudo chown -R codespaces /home/codespace/workspace/berry

Hmm, everything is owned by root. I don’t know why, I just created the codespace and ran yarn in a terminal – shouldn’t the files be owned by the codespace user by default?

Unless you ran “sudo yarn install” (or a script did), it should be owned by the codespaces user. This might be

One quick clarifications - currently the files are owned by root, but are globally “r/w”, so that isn’t a problem most of the time. Now, if you type “sudo yarn install” then they may not be globally “r/w”. will cause the owner to be codespace.

However, if there is a script that does a chmod that specifies explicit permissions to deny everyone (instead of doing something like +x), this could happen. That’s why it needs to get fixed.

This change has been deployed! Files in the workspace for any new Codespace are now owned by the remoteUser, which allows things like chmod +x to work without sudo.