multipass
multipass copied to clipboard
Insufficient permissions inside created Instance to install `npm` packages
Describe the bug
When created instance of Ubuntu 20.x and mount a folder to be shared - cannot install npm
packages:
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, open '/server/node_modules/tiny-lru/package.json'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, open '/server/node_modules/through/readme.markdown'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, open '/server/node_modules/typescript/LICENSE.txt'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, open '/server/node_modules/vscode-typescript-languageservice/out/services/codeAction.js'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, open '/server/node_modules/string.prototype.padend/.nycrc
I cannot install the packages on the host and run on Ubuntu because it seems like the installed packages are not compatible with Ubuntu (my host is MacOS), so it needs to install packages itself.
Am I mounting the folder wrongly that leaves the instance with lack of permissions or is there something else that might be missing?
To Reproduce How, and what happened?
-
multipass mount ./project-folder-on-host instance-name:/name-alias
- make sure npm and nodejs are installed
-
npm install
inside the mounted folder
Expected behavior Packages to be able to install with sufficient permissions for the created instance to write / read files
Logs Above
Additional info
- OS: MacOS monterey 12.3.1
-
multipass version
- 1.8.1 -
multipass info --all
Name: delighted-stoat
State: Running
IPv4: 192.168.64.4
Release: Ubuntu 20.04.4 LTS
Image hash: ccc11e625acd (Ubuntu 20.04 LTS)
Load: 0.00 0.03 0.03
Disk usage: 1.7G out of 4.7G
Memory usage: 163.4M out of 970.0M
Mounts: /Users/**/Desktop/altv-dayz => /server
UID map: 501:default
GID map: 20:default
Additional context Add any other context about the problem here.
Hi @OlegGulevskyy, I do not see this as a bug in Multipass. I can mount a folder I own on an instance in MacOS, even under /
, and manipulate files on that mount. I suggest you to check npm
setup, there is nothing wrong on the Multipass side.
On the other hand, do you have write permissions (in the host) on the folder you are mounting?
I can perfectly reproduce your setup (without npm
, though) and be able to create files on the mounted folder, on both the instance and the host. What seems strange to me is that the mounted folder contains two stars in the name, how is the instance folder named? In particular, is the user named **
?
On the other hand, do you have write permissions (in the host) on the folder you are mounting?
I can perfectly reproduce your setup (without
npm
, though) and be able to create files on the mounted folder, on both the instance and the host. What seems strange to me is that the mounted folder contains two stars in the name, how is the instance folder named? In particular, is the user named**
?
Nope, sorry for the confusion - ** 2 stars was just a placeholder for the user name of the PC, nothing important
The issue is exactly with npm
though, I cannot install any packages with given in the initial message logs, as if npm can't read necessary files.
No issues with npm on plain ubuntu or mac (host) systems.
Where are you running npm
, on the host or the instance? Is the folder empty when you run it?
Can you give us a complete sequence to reproduce the bug?
Where are you running
npm
, on the host or the instance? Is the folder empty when you run it?
I was running npm
on the instance. With both, node_modules
present and completely removed - the same result
Running npm
on the host does not lead to any issues
Complete sequence is:
- Have a npm project on your host machine, without
node_modules
- Mount the folder to your ubuntu instance
-
cd
to the folder on your ubuntu instance - run
npm install
to install project dependencies
Thank you for looking into it
I couldn't reproduce, npm install
worked. I suggest you to check the permissions of the folders in the host.
I couldn't reproduce,
npm install
worked. I suggest you to check the permissions of the folders in the host.
sorry for stupid question - is there anything else I can check apart from chmod
? As the folder has 777 permissions set on host machine right now while having an error
That check should suffice.
Did you check removing the mount, restarting the instance and mounting again?
That check should suffice.
Did you check removing the mount, restarting the instance and mounting again?
Just tried:
- creating new instance
- making sure to be mounted folder has
chmod 777
- mount the folder
- enter new instance with
shell
- install nodejs 16.x + npm
- navigate to the folder and run
npm install
the same result unfortunately
does it matter that the shared folder in virtual instance is on the same level as /tmp
/etc
and so ? instead of ~
That shouldn't be a problem, but you can try in another place. Do you have sufficient disk space? Did you try with another project using npm
?
Just to echo @luis4a0 here, I'm unable to reproduce either.
Could you also list which npm
projects you have installed on your host's project directory and how exactly you installed them?
I get this too randomly. Sometimes installs work just fine, other times they start to get that error partway through the install. They'll be able to create a bunch of directories leading up to that point, but then suddenly partway through it seems like it loses permission somehow.
@OlegGulevskyy, @Qard: I wonder if you're hitting a maxfiles limit? We have seen permissions being denied when trying to open files beyond that. Could you try these instructions and see if that helps you by any chance?
@OlegGulevskyy @Qard @ricab I was able to fix this issue on Monterey, it was indeed a maxfiles limit problem. The trick is to reload the com.canonical.multipassd.plist
file after rebooting, so the new files limits are activated. Instructions taken from:
https://mampsupportforum.com/viewtopic.php?t=155
https://serverfault.com/questions/194832/how-to-start-stop-restart-launchd-services-from-the-command-line
- Create the
/Library/LaunchDaemons/limit.maxfiles.plist
file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>64000</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
- Create the
/Library/LaunchDaemons/limit.maxproc.plist
file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>12784</string>
<string>14176</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
- Change their permissions:
sudo chown -R root:wheel /Library/LaunchDaemons/limit.maxproc.plist
sudo chown -R root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
- Reboot
- Reload multipass (needs to be done after each reboot, a better solution is needed):
sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist
I fix it by running npm install out of ubuntu instance shell. Use your default terminal and run npm install
in folder of your mac(not ubuntu instance)
Looks like this issue is back with the latest Ventura version... When getting the error, run the following (thanks to https://developer.apple.com/forums/thread/735798):
multipass stop --all
sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
sudo launchctl limit maxfiles 256 unlimited
sudo launchctl limit maxfiles 128000 524288
sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist
I have not checked how to persist this change yet, so it needs to be done after each reboot.
Edit: tested on Sonoma 14.0, works as expected.