Skip to content

Insufficient permissions inside created Instance to install npm packages #2528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
OlegGulevskyy opened this issue Apr 18, 2022 · 16 comments
Open

Comments

@OlegGulevskyy
Copy link

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?

  1. multipass mount ./project-folder-on-host instance-name:/name-alias
  2. make sure npm and nodejs are installed
  3. 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.

@luis4a0
Copy link
Contributor

luis4a0 commented Apr 18, 2022

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.

@luis4a0 luis4a0 closed this as completed Apr 18, 2022
@luis4a0 luis4a0 reopened this Apr 18, 2022
@luis4a0
Copy link
Contributor

luis4a0 commented Apr 18, 2022

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 **?

@OlegGulevskyy
Copy link
Author

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.

@luis4a0
Copy link
Contributor

luis4a0 commented Apr 18, 2022

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?

@OlegGulevskyy
Copy link
Author

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:

  1. Have a npm project on your host machine, without node_modules
  2. Mount the folder to your ubuntu instance
  3. cd to the folder on your ubuntu instance
  4. run npm install to install project dependencies

Thank you for looking into it

@luis4a0
Copy link
Contributor

luis4a0 commented Apr 18, 2022

I couldn't reproduce, npm install worked. I suggest you to check the permissions of the folders in the host.

@luis4a0 luis4a0 removed the bug label Apr 18, 2022
@OlegGulevskyy
Copy link
Author

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

@luis4a0
Copy link
Contributor

luis4a0 commented Apr 18, 2022

That check should suffice.

Did you check removing the mount, restarting the instance and mounting again?

@OlegGulevskyy
Copy link
Author

That check should suffice.

Did you check removing the mount, restarting the instance and mounting again?

Just tried:

  1. creating new instance
  2. making sure to be mounted folder has chmod 777
  3. mount the folder
  4. enter new instance with shell
  5. install nodejs 16.x + npm
  6. 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 ~

@luis4a0
Copy link
Contributor

luis4a0 commented Apr 18, 2022

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?

@townsend2010
Copy link
Contributor

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?

@Qard
Copy link

Qard commented Jul 26, 2022

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.

@ricab
Copy link
Collaborator

ricab commented Jul 28, 2022

@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?

@joanniclaborde
Copy link

@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

  1. 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>
  1. 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>
  1. Change their permissions:
sudo chown -R root:wheel /Library/LaunchDaemons/limit.maxproc.plist
sudo chown -R root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
  1. Reboot
  2. 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

@LLuchiKK
Copy link

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)

@joanniclaborde
Copy link

joanniclaborde commented Sep 5, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants