Yii2 Basic - Permission error in web/assets - chmod(): Operation not permitted

Hello, I’ve run into an issue after installing the basic Yii template. When try to load it up I’m met with a chmod error when it’s trying to generate folders in the web/assets folder: “Failed to change permissions for directory “/mnt/c/Users/Liam/Documents/projects/yii2-app-basic/web/assets/5cb0b232”: chmod(): Operation not permitted”. After reloading 3 times to generate the 3 folders, the page loads but without any styling or assets loaded.

For some background, I’m running this on WSL with Ubuntu 20.04.5 LTS with a symlink to Windows where the project files are. When installing I’ve tried running composer create-project --prefer-dist yiisoft/yii2-app-basic with and without sudo with the same effect.

After running that command, it returns this at the end (result below), so it appears to have set the correct permissions for the web/assets folder, so I’m unsure if there’s something I’ve done incorrectly.

> yii\composer\Installer::postCreateProject
chmod('runtime', 0777)...done.
chmod('web/assets', 0777)...done.
chmod('yii', 0755)...done.
> yii\composer\Installer::postInstall

If anyone could point me in the right direction I’d be really grateful, and please let me know if there’s any other information/details you need from me :slight_smile:

Folders web/assets and runtime/ need to have 0777 permision
so just do
sudo chmod -Rv 777 /mnt/c/Users/Liam/Documents/projects/yii2-app-basic/web/assets
sudo chmod -Rv 777 /mnt/c/Users/Liam/Documents/projects/yii2-app-basic/runtime

Hi Stefano,

Many thanks for your reply. I’ve run those commands and checked using ls -l that those permissions have been applied and it returned mode of '/mnt/c/Users/Liam/Documents/projects/yii2-app-basic/web/assets' retained as 0777 (rwxrwxrwx), so that’s good they’ve got the correct permissions, but unfortunately the issue is still coming up when I try to load any of the pages up. Do you think this could be an issue with WSL/Ubuntu rather than Yii?

Sounds like is an issue with the WSL. Definitely not Ubuntu thing.
May be try restarting the server in case there is cached folders.
Another test is delete the folder(s) and recreate and then apply permission with server off

1 Like

Permission inheritance in Windows?

Edit: This may help (to explain why)

Changing file permissions on an existing Windows file using chmod

The result depends on if the file already has existing metadata.

Please keep in mind that you cannot give yourself more access than what you have on Windows, even if the metadata says that is the case. For example, you could set the metadata to display that you have write permissions to a file using chmod 777, but if you tried to access that file you would still not be able to write to it.

Related info

1 Like

Sorry I hadn’t replied to the thread for a while. It was definitely a permissions issue with WSL/Windows, I couldn’t find a direct fix for it, but I found a workaround a little afterwards, so I thought I’d share the solution.

In the end I used XAMP and installed the basic package there to run & generate the assets that were causing the issues and to my surprise it worked. After that I copied the basic directory within XAMP and moved the files over to WSL, and everything went smoothly. If I find a proper solution I’ll post an update, thanks for your help both :slight_smile:

1 Like