tar EPERM: operation not permitted, futime
Asked Answered
F

6

29

I have a node:alpine Docker image. When I run the image as a root user, I have no problems, but when I use another user and I try to do npm install I receive a lot of errors from package extraction:

npm WARN tar EPERM: operation not permitted, futime

After 5000 WARN messages, I see this on the npm install log:

npm timing action:extract Completed in 276816ms
npm timing action:finalize Completed in 172ms

And no more, the npm install process is completely hang.

Anybody knows this error and know how to avoid it?

Foliage answered 5/6, 2019 at 9:31 Comment(0)
M
100

Solution for WSL:

I solved this by mounting C:/ with default permissions bound to my user instead of root. I followed the guide here: https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/

sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000,umask=22,fmask=111

This mounts all files on the C drive as my user instead of root. Therefore sudo is not needed to run npm i

Mouldy answered 16/10, 2019 at 13:12 Comment(7)
Worked like a charm. Thank you so much.@Foliage this should be the accepted answer.Sigil
Works on Ubuntu 20.04 LTS as well. Thanks a lot!Gotthelf
if you get a message that says C is busy -> terminate wsl from powershell wsl --terminate Ubuntu-20.04 or with ubuntu 18 etc. Then start wsl2 ubuntu againg and cd / then try againPotentiality
Thanks! This is what worked for me!Fetiparous
Thanks - worked for me as well, but couldn't run the first line sudo umount /mnt/c. I got an error that target is busy. I proceeded with the second command and after that npm i worked fine.Magocsi
I run both commands successfully but now it says zsh: permission denied: npm I think, I messed up with my permissions. How can I revert this ?Leshia
Failed to work few times and then I decided to check it for disk d. And it works! Thanks a lotCalculating
B
11

I had this in Windows Linux Subsystem too, after moving a project from Windows to Linux. I failed to fix it with

rm -rf node_modules
rm package-lock.json
npm cache clear --force
chown -R username:username *
npm install

None of this worked.


futime errors are caused by the tar utility not having enough rights to perform the necessary actions to expand the .tar files used by npm and the node modules.

In the case of Alpine Linux, you may need to unpack as root and then chown the files, or create a folder owned as the user with the right permissions.

For Windows Subsystem for Linux, it doesn't seem to work with folders under /mnt/c and refuses to change permissions. Setting them in Linux has no effect, and setting them in Windows doesn't seem to make any difference either - adding full control to the 'Everyone' principle doesn't solve this.


(probable) solution for Alpine:

sudo mkdir project_folder
sudo chown username project_folder
cd project_folder
...  

Solution for WSL:

Move the folder into the WSL folder, eg. mv project ~\ so that permissions work correctly.

Blakley answered 20/9, 2019 at 16:33 Comment(2)
Moving the project from my Windows 10 to WSL2 ~ directory solved it for me. Thanks a bunch!Vizor
It did work for me after struggling for a little bit. thank you so much.Liew
D
0

Not elegant solution but it works... In your application directory:

rm -rf node_modules
mkdir /home/your_user/node_modules
ln -s /home/your_user/node_modules node_modules
npm install
Delineation answered 23/12, 2019 at 13:36 Comment(1)
Please take the tour and also how to answerJudicatory
E
0

Enable "Developer Mode" on your computer, then restart to resolve this issue!

Here's a guide on how to enable Developer Mode if you need it: https://www.wikihow.com/Enable-Developer-Mode-in-Windows-10#/Image:Enable-Developer-Mode-in-Windows-10-Step-5-Version-3.jpg

Electromagnetism answered 18/6, 2021 at 0:47 Comment(0)
J
0

if you get this error while using a tool like multipass or docker and you just mount your home directory or wherever your code is into that environment. you may also get this error.

in that case you can avoid such errors by simply pulling your code from your repository onto that environment instead of trying to work on your mounted code from host.

this way is also more clean as you do not provide more permissions as needed. which can always be a security issue.

Johnny answered 1/10, 2022 at 6:14 Comment(0)
L
-1

Try with this command might help :

npm install --user
Lanthorn answered 5/6, 2019 at 9:42 Comment(1)
tried this, same issue... (i'm not using docker, but Windows LInux Subsystem)Tin

© 2022 - 2024 — McMap. All rights reserved.