hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.22k stars 4.43k forks source link

vagrant-nfs tries to execute /etc/init.d/nfs-kernel-server on NixOS #13296

Open GeFrIt42 opened 10 months ago

GeFrIt42 commented 10 months ago

Debug output

https://gist.github.com/GeFrIt42/8a808adbc607c9c370113a6413a7c03b

Expected behavior

founder should be mounted via nfs. this was working 6 month ago.

Actual behavior

INFO interface: error: The executable '/etc/init.d/nfs-kernel-server' Vagrant is trying to run was not found in the PATH variable. This is an error. Please verify this software is installed and on the path. The executable '/etc/init.d/nfs-kernel-server' Vagrant is trying to run was not found in the PATH variable. This is an error. Please verify this software is installed and on the path. INFO interface: Machine: error-exit ["Vagrant::Errors::CommandUnavailable", "The executable '/etc/init.d/nfs-kernel-server' Vagrant is trying to run was not\nfound in the PATH variable. This is an error. Please verify\nthis software is installed and on the path."]

Reproduction information

Vagrant version

Vagrant 2.3.4 vagrant-libvirt (0.8.2, system)

Host operating system

Distributor ID: NixOS Description: NixOS 23.11 (Tapir) Release: 23.11 Codename: tapir

Guest operating system

config.vm.box = "generic/ubuntu2204"

Steps to reproduce

  1. Vagrant up

Vagrantfile


# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "generic/ubuntu2204"
  config.vm.box_check_update = true
  config.vm.hostname = "myHostName-#{Random.hex(1)}"
  config.vm.define :myVmName
  # hardware Config
  config.vm.provider :libvirt do |libvirt|
    libvirt.cpus = 7
    libvirt.memory = 8192
  end
  # ssh config
  config.ssh.forward_agent = true
  config.ssh.forward_x11 = true
  config.vm.synced_folder ".", "/home/vagrant/repo", type: "nfs", nfs_version: 4
 end

extra info

nfs server is running, configured accordingly https://nixos.wiki/wiki/Vagrant this mount was actually working 6 months ago.

image

GeFrIt42 commented 10 months ago

after digging, NixOs uses systemd, Vagrant supposed to detect if the platform uses systemd or sysV https://github.com/hashicorp/vagrant/blob/9b460ecedefa45a557b1c13c63449839819dc220/plugins/hosts/linux/cap/nfs.rb

          if Vagrant::Util::Platform.systemd?
             "systemctl status --no-pager #{nfs_service_name_systemd}"
          else
            "/etc/init.d/#{nfs_service_name_sysv} status"
          end

inspiring myself from a old issue #1125 I have created a /etc/init.d/nfs-kernel-server with execution permission

#!/bin/sh
echo $@ >> /home/<your usename>/vagrant.log

it turned out that vagrant try execute /etc/init.d/nfs-kernel-server once with the parameter status on vagrant up and vagrant reload, despite that folders seems to be mounted and working normally.

image

this seems working for now as workaround though very ugly.