vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

synced_folder fails for NFS on Sonoma 14.4

Open dfreudenberger opened this issue 11 months ago • 16 comments

Debug output

https://gist.github.com/dfreudenberger/7e894870dc739cba7876fef4983c8508

Expected behavior

synced_folder should mount the specified path using NFS.

Actual behavior

Apple decided to limit the access to kickstart which is currently used to restart the NFS daemon. Therefore the mount operation fails.

Edit: It seems like Vagrant doesn't actually use kickstart by itself; instead, it runs "sudo nfsd restart" which causes the error mentioned. Perhaps modifying this line to use update instead of restart could solve the problem.

sudo nfsd restart
Could not kickstart service "com.apple.nfsd": 1: Operation not permitted
/bin/launchctl exited with status 1

Reproduction information

Vagrant version

Vagrant 2.4.1

Host operating system

MacOS Sonoma 14.4

Guest operating system

Fedora

Steps to reproduce

  1. vagrant up

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    config.vm.box = "bento/fedora-latest"

    config.vm.provider "parallels" do |prl|
        prl.update_guest_tools = false
    end

    config.vm.synced_folder '~/dev', "/data", :type => 'nfs', :nfs_version => 3
end

dfreudenberger avatar Mar 14 '24 09:03 dfreudenberger

I am working with @dfreudenberger and having the same problem.

It looks like replacing "nfsd restart" with "nfsd update" here. Though I am not able to run vagrant from a checkout and install the parallels plugin and therefore not really able to provide a fix right now.

bjoernhaeuser avatar Mar 14 '24 11:03 bjoernhaeuser

I too am experiencing the same problem.

emek-lu avatar Mar 19 '24 06:03 emek-lu

We are affected too:

==> devserver: Exporting NFS shared folders...
==> devserver: Preparing to edit /etc/exports. Administrator privileges will be required...
Password:
Could not kickstart service "com.apple.nfsd": 1: Operation not permitted
/bin/launchctl exited with status 1

bmorg avatar Mar 20 '24 06:03 bmorg

Same here

Stark-X avatar Mar 24 '24 10:03 Stark-X

I'm also on 14.4 and I'm also having this same issue:

==> default: Installing NFS client... ==> default: Exporting NFS shared folders... ==> default: Preparing to edit /etc/exports. Administrator privileges will be required... Could not kickstart service "com.apple.nfsd": 1: Operation not permitted /bin/launchctl exited with status 1 ==> default: Mounting NFS shared folders... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!

mount -o vers=3 10.211.55.2:/Users/user/Work/test.com/site /vagrant-nfs-test.com

Stdout from the command:

Stderr from the command:

mount.nfs: an incorrect mount option was specified

Rob-Voss avatar Mar 25 '24 14:03 Rob-Voss

Yes, unfortunately bumped into the same issue today...

Twansparant avatar Mar 26 '24 13:03 Twansparant

Also happens with Sonoma 14.4.1 :(

bjoernhaeuser avatar Mar 26 '24 13:03 bjoernhaeuser

Same - manually running sudo nfsd update in terminal resolves

unlovedsam avatar Mar 26 '24 14:03 unlovedsam

@bjoernhaeuser

Though I am not able to run vagrant from a checkout and install the parallels plugin and therefore not really able to provide a fix right now.

I don't think anyone else has mentioned it, but I'm having the same issue with VirtualBox - this issue isn't Parallels specific.

adherzog avatar Mar 27 '24 15:03 adherzog

FYI I have the same issue issue using VMWare Fusion

lookareyellow avatar Mar 28 '24 07:03 lookareyellow

I came upon this thread while searching for the error message. Unrelated to Vagrant, I have this issue on my Mac. The update command suggested above didn’t help. However, I could start nfsd by doing sudo launchctl start nfsd. I hope this helps.

gapop avatar Mar 30 '24 13:03 gapop

sudo nfsd update

It's working, thanks.

nicolasverlhiac avatar Apr 03 '24 20:04 nicolasverlhiac

Same - manually running sudo nfsd update in terminal resolves

@unlovedsam What exactly did you do? I've run the command before the vagrant up command - no change. After the vagrant up command exits, no change. In a separate terminal at the point when the kickstart error is emitted, no change. Still unable to mount my synced_folder.

jason-apolline avatar Apr 07 '24 11:04 jason-apolline

Same - manually running sudo nfsd update in terminal resolves

@unlovedsam What exactly did you do? I've run the command before the vagrant up command - no change. After the vagrant up command exits, no change. In a separate terminal at the point when the kickstart error is emitted, no change. Still unable to mount my synced_folder.

It seems to be a UDP issue in my case with Ubuntu 22.04. Forcing UDP off in the Vagrantfile seems to sort that out (also probably with the help of sudo nsfd update). This is odd as I have other 22.04 VMs and didn't experience this issue, however I can't recall if I have used them since updating to Sonoma.

jason-apolline avatar Apr 07 '24 13:04 jason-apolline

I’m also having this issue but couldn't fix it by running sudo nfsd update or sudo launchctl start nfsd. Does anyone has any idea why? I am on macOS Sonoma 14.4.1. Thanks

gutobenn avatar Apr 26 '24 00:04 gutobenn

[Update] @robert914 solution below solved this issue the for me. ✅

[OP] All I can say is that I now have it working but I am not sure why having tried every suggested combination above and these combinations were not previously working.

Most recently I did the following:

  • ensured I had the latest Vagrant by using the brew cask recommended on the Hashicorp web page for Vagrant brew tap hashicorp/tap and brew install hashicorp/tap/hashicorp-vagrant
  • ensured that /private/etc/sudoers had aliases as recommended on Hashicorp website (see below)
  • vagrant plugin update to ensure Parallels (my VM provider) client plugin was up to date
  • sudo nfsd update in one terminal window
  • vagrant ssh in another terminal window to see that the guest virtual machine actually could now see my host machine files

But honestly I can't say for certain which of these got NFS working between host and guest files. AND, even though I am manually checking that the files are in sync, the launchctl kickstart error message is still being generated

FYI I added a file to /private/etc/sudoers.d that contains:

Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE

Note that changing /sbin/nfsd restart above to /sbin/nfsd update still causes the kickstart error

iainhouston avatar Apr 29 '24 00:04 iainhouston

Same - manually running sudo nfsd update in terminal resolves

@unlovedsam What exactly did you do? I've run the command before the vagrant up command - no change. After the vagrant up command exits, no change. In a separate terminal at the point when the kickstart error is emitted, no change. Still unable to mount my synced_folder.

I use sudo nfsd update in a second window right after vagrant printed these lines:

==> default: Exporting NFS shared folders... ==> default: Preparing to edit /etc/exports. Administrator privileges will be required... Could not kickstart service "com.apple.nfsd": 1: Operation not permitted /bin/launchctl exited with status 1 ==> default: Mounting NFS shared folders...

The nfsd update is necessary after /etc/exports was modified.

HTH, Patrick

pmhausen avatar Jul 09 '24 14:07 pmhausen

I was able to get the error to go away and have it work with vagrant up of existing and/or new boxes, by doing the following edit to my Vagrant install on my MacBook:

sudo vim /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/hosts/bsd/cap/nfs.rb
# change line 163 from the following:
          ["sudo", "nfsd", "restart"]
# to this: (i.e. change 'restart' to 'update')
          ["sudo", "nfsd", "update"]

robert914 avatar Jul 09 '24 15:07 robert914

@robert914 solution solved issue the for me. ✅

FYI I added a file to /private/etc/sudoers.d (sudo visudo -f /etc/sudoers.d/vagrant-exports) to bypass having to provide a sudo password when bringing up Vagrant. It contains:

Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd update
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE

iainhouston avatar Jul 09 '24 15:07 iainhouston

I was able to get the error to go away and have it work with vagrant up of existing and/or new boxes, by doing the following edit to my Vagrant install on my MacBook:

sudo vim /opt/vagrant/embedded/gems/gems/vagrant-2.4.1/plugins/hosts/bsd/cap/nfs.rb
# change line 163 from the following:
          ["sudo", "nfsd", "restart"]
# to this: (i.e. change 'restart' to 'update')
          ["sudo", "nfsd", "update"]

Thanks a lot for that fix. But ... when is this issue going to be fixed in a Vagrant release? To the "naive" developer who doesn't know how to search github for issues and doesn't want to manually patch their Vagrant installation, Vagrant is unusable on Mac OS for over 4 months, now.

This is not the first time this happens. Not NFS related, but I remember some breakage in the networking functions. If needed I'll dig for the issue.

People rely on this tool for their workflow. If I put the same level of confidence in any product by Hashicorp I best stay away from them as far as I can manage. This product is a major infrastructure building block for my team.

What's the problem? Is Vagrant abandonware? For me it's one of the best things since sliced bread, but if I cannot count on it working when I need it ... well.

Ironically I am holding a half-day tutorial at this year's EuroBSDCon in Dublin about Vagrant. And I did the same last year in Coimbra. I'd hate to tell my attendees "oh, and BTW, Vagrant is broken, you need to either manually patch it or enter this command in a second terminal window with proper timing ..."

Just a wee bit frustrated, Patrick

EDIT: here's the old issue. Vagrant unusable for 6 months. https://github.com/hashicorp/vagrant/issues/12681

pmhausen avatar Jul 29 '24 18:07 pmhausen

Hey everyone. My apologies on the delay for getting this issue addressed and the frustration it has caused. A fix has been implemented and merged (#13490). It will be included in the next release that will be shipped within the next couple weeks.

Cheers!

chrisroberts avatar Aug 27 '24 23:08 chrisroberts