7

I am using Windows 10's Linux subsystem where I installed Jekyll but when I run bundle exec jekyll serve it gives me:

jekyll 3.8.6 | Error: Operation not permitted @ apply2files - /mnt/e/Work/project/_site/images/banner.jpg

I know there are some incompatibilities with Windows and Linux permissions, because all my files are owned by root for some reason, but there is a fix to this issue?

I found an answer here https://scottdorman.blog/2019/02/27/running-jekyll-on-wsl/ where the author says I have to close and reopen the bash, but it doesn't work.

Ionel Lupu
  • 2,467
  • 5
  • 27
  • 46

2 Answers2

17

These "operation not permitted" errors seem to be related to user rights or ownership.

I have seen strange errors on colleagues' MAC computers. The command ls -al showed that certain folders were owned by root.

If this applies to you, try to change/transfer ownership to your user with these commands:

  • sudo chmod -R 777 /mnt/e/Work/project/
  • sudo chown -R youruser /mnt/e/Work/project/

The difference between chmod and chown is simple:

  • chmod changes modes
  • chown changes ownership

Note: This is explained in detail on unixtutorial.org.

For the Windows Linux Subsystem, I have found this old blogpost devblogs.microsoft.com from January 2018:

How did permissions work in the past?
Prior to Build 17063, all files/folders list “root” as the owner and belonged to the group “root”. The permission bits on each file/folder was derived from Windows permissions–no write bit checked for Windows meant no write bit set in WSL.
Additionally, attempting to chmod or chown on a file/folder resulted in a no-op (they wouldn’t do anything!)

How do permissions work now?
For files that don’t have metadata, we apply the same approach as what is described in pre-17063 builds. But now, chmod/chown can assign metadata to the file or folder. Newly created files in WSL will be created with metadata by default and will respect the mount options you’ve set (discussed later) or the permissions you pass when executing a mkdir/open.

And, I have found this SO post: chmod WSL (Bash) doesn't work, which states that it's enough to unmount and re-mount the drive to make chmod and chown work (after the mentioned WSL update).

Christian
  • 2,721
  • 3
  • 21
  • 36
  • When I execute `ls -al` it does show that root owns the files and folders. When I executed your command above it does not appear to assign owner to my user. – Mike Cole Aug 20 '19 at 14:56
  • @Christian [Pre](https://i.imgur.com/uD7EYs5.png) Command: `sudo chown -R mike /mnt/c/workspace/github/github-pages-demo.github.io/` [Post](https://i.imgur.com/EMQi2lc.png) – Mike Cole Aug 20 '19 at 17:27
  • Can you change the ownership of single files? – Christian Aug 21 '19 at 06:47
  • @Christian no I cannot – Mike Cole Aug 21 '19 at 15:41
  • I revisited this today. It just worked. I assume that a combination of restarting my machine, plus restarting WSL, accomplished the same as the extra link above. – Mike Cole Aug 26 '19 at 14:46
  • 1
    It's odd because I just checked out Jekyll sites where I never changed any permissions, and they all appear to be owned by my user instead of root, and they just work. A WSL quirk? Either way, I gained some valuable knowledge, so thank you. – Mike Cole Aug 26 '19 at 14:47
11

As @Mike Cole mentioned above in the comments: If you are using wsl this can happen. I resolved this by restarting my machine and magically it works now.

kicksent
  • 111
  • 1
  • 3
  • 1
    Confirmed. Had this problem after installing fresh copy of Ubuntu 20.04 in WSL2. Files were listed as owned by root, but after rebooting Windows, they're now listed under my username – David Gardiner Apr 26 '20 at 11:07