The problem
This error also occoured for me on WSL. But I'm happy to have found a fix that doesn't require me to manually chmod permissions into directories. The error is verbose enough to tell me its an issue with my chmod command not allowing me to do that, rather than something I should be doing for every single folder on my system each time I want to rbenv
into it to work on something like Jekyll.
ion not permitted @ apply2files - /mnt/e/source/repos/work/ecs-saber/docs (Errno::EPERM)
Little research
EPERM is a validation check, a deep dive would reveal this is a safety feature that prevents you, even if you have access, from being able to do anyhting to file permissions with Ruby on directories / files that you are not a part of the group ownership on.
So how did I fix it?
I fixed it via adding WSL DrvFs speclines to my /etc/wsl.conf
file (see: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig )
The rest of this document breaks down the steps.
1. Configure your WSL root account:
You should have a root password, because you won't have access to /etc
, even with your user's sudo command, so first:
me@PRIVATE-PC:/mnt/c/Users/private$ sudo passwd
[sudo] password for me:
New password:
Retype new password:
passwd: password updated successfully
Now login as root
su -
Password:
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux *.*.*.*-microsoft-standard-WSL2 x86_64)
...
This message is shown once a day. To disable it please create the
/root/.hushlogin file.
root@PRIVATE-PC:~# _
Now, good little admins should also harden their root accounts, but this isn't the scope of this answer. You can move forward for now, but you should go back and do this. I am obligated to tell you that about root access, anywhere, at any time (that includes at 3AM, Junior Devs, where the greatest mistakes happen with the root shell is when we are tired)
Put a string on your finger to harden root shell -- Circulation is important, don't actually do this physically, I need you to keep your fingers.
2. Apply /etc/wsl.conf
change
Now that you are root, you can give the /etc
partiiton the fix:
Write /etc/wsl.conf
, just copy/paste on command line and press [enter]:
cat <<'EOF' > /etc/wsl.conf
[automount]
enabled = true
root = /mnt
options = "metadata,uid=1000,gid=1000,umask=022,case=off"
mountFsTab = false
EOF
Why umask=022
?
Octal permissions to exclude (octal subtract) from files and directories. This produces a permission set of 0755
where your user has the ability to read, write, and execute, but your overlaying group and everyone can only read and execute.
3. Restarting without rebooting
Now, do a flip. (Simulate a restart of WSL) See: https://superuser.com/questions/1126721/rebooting-ubuntu-on-windows-without-rebooting-windows
I'll improve the solution presented by saying you don't have to reboot, if you know the right commands.
root@PRIVATE-PC:~# exit
logout
me@PRIVATE-PC:/mnt/c/Users/private$ exit
ohmyPOSH> wsl -d Ubuntu-20.04 --shutdown
ohmyPOSH> wsl -t Ubuntu-20.04
ohmyPOSH> Restart-Service LxssManager
Just count to ten in your head (Microsoft's stated rule is 8 seconds), get up have a stretch, then log back in via Windows Terminal PowerShell tab:
ohmyPOSH> wsl -d Ubuntu-20.04 -u me
Check the permissions on your jekyll project folder:
me@PRIVATE-PC:/mnt/c/users/me$ cd /mnt/e/source/repos/work/ecs-saber/docs
me@PRIVATE-PC:/mnt/e/source/repos/work/ecs-saber/docs$ ls -lah
drwxr-xr-x 1 me me 4.0K Sep 1 04:20 .
drwxr-xr-x 1 me me 4.0K Sep 1 03:49 ..
-rwxr-xr-x 1 me me 56 Sep 1 04:20 .gitignore
-rwxr-xr-x 1 me me 6 Sep 1 03:50 .ruby-version
-rwxr-xr-x 1 me me 419 Sep 1 04:20 404.html
-rwxr-xr-x 1 me me 2.1K Sep 1 04:20 _config.yml
drwxr-xr-x 1 me me 4.0K Sep 1 04:20 _posts
And now they are owned by your user with permissions set to a much less unnerving 0755
! You no longer have to do this for every single directory, in fact, if you check others, like your user folder:
me@PRIVATE-PC:/mnt/c/users/me$ ls -lah
drwxr-xr-x 1 me me 512 Sep 1 03:59 .
drwxr-xr-x 1 me me 512 Aug 28 04:45 ..
drwxr-xr-x 1 me me 512 Aug 30 07:08 .aws
drwxr-xr-x 1 me me 512 Aug 30 07:08 .azure
drwxr-xr-x 1 me me 512 Aug 30 10:03 .cache
drwxr-xr-x 1 me me 512 Aug 30 09:53 .conda
-rwxr-xr-x 1 me me 4 Aug 31 07:32 .condarc
drwxr-xr-x 1 me me 512 Aug 28 12:19 .docker
...
You'll have a lot of the same.
Onward
me@PRIVATE-PC:/mnt/e/source/repos/work/ecs-saber/docs$ jekyll new . --force
Running bundle install in /mnt/e/source/repos/work/ecs-saber/docs...
Bundler: Fetching gem metadata from https://rubygems.org/............
Bundler: Resolving dependencies...
Bundler: Using public_suffix 5.0.0
Bundler: Using bundler 2.3.21
Bundler: Using colorator 1.1.0
Bundler: Using concurrent-ruby 1.1.10
Bundler: Using eventmachine 1.2.7
Bundler: Using http_parser.rb 0.8.0
Bundler: Using ffi 1.15.5
Bundler: Using forwardable-extended 2.6.0
Bundler: Using rexml 3.2.5
Bundler: Using rb-fsevent 0.11.2
Bundler: Using liquid 4.0.3
Bundler: Using mercenary 0.4.0
Bundler: Using rouge 3.30.0
Bundler: Using unicode-display_width 1.8.0
Bundler: Using safe_yaml 1.0.5
Bundler: Using addressable 2.8.1
Bundler: Using i18n 1.12.0
Bundler: Using sassc 2.4.0
Bundler: Using rb-inotify 0.10.1
Bundler: Using pathutil 0.16.2
Bundler: Using em-websocket 0.5.3
Bundler: Using terminal-table 2.0.0
Bundler: Using jekyll-sass-converter 2.2.0
Bundler: Using kramdown 2.4.0
Bundler: Using listen 3.7.1
Bundler: Using kramdown-parser-gfm 1.1.0
Bundler: Using jekyll-watch 2.2.1
Bundler: Using jekyll 4.2.2
Bundler: Fetching jekyll-seo-tag 2.8.0
Bundler: Fetching jekyll-feed 0.16.0
Bundler: Installing jekyll-feed 0.16.0
Bundler: Installing jekyll-seo-tag 2.8.0
Bundler: Fetching minima 2.5.1
Bundler: Installing minima 2.5.1
Bundler: Bundle complete! 7 Gemfile dependencies, 31 gems now installed.
Bundler: Use `bundle info [gemname]` to see where a bundled gem is installed.
New jekyll site installed in /mnt/e/source/repos/work/ecs-saber/docs
🎉 No more EPERM validation failures.