sync_folderで発生したエラーと解決策
Vagrantfileの定義にsync_folder
を指定してphpのCodeIgniterを使ったシステム開発をしようかなと思ったら、エラーが出てしまった。
以下はVagrantfileの定義です。
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "centos/8"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
config.vm.provision :shell, :path => "./provision.sh", :privileged => true
config.vm.synced_folder "./codeigniter", "/var/www/html/codeigniter"
end
vagrant up
すると最後のほうで赤文字で以下のエラーが出ていました。
vagrantupで出たエラー
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/usr/sbin/rcvboxadd setup
Stdout from the command:
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules. This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel
4.18.0-193.19.1.el8_2.x86_64.
VirtualBox Guest Additions: Look at /var/log/vboxadd-setup.log to find out what
went wrong
Stderr from the command:
modprobe vboxguest failed
The log file /var/log/vboxadd-setup.log may contain further information.
このエラーメッセージが指摘しているように/var/log/vboxadd-setup.log
のファイルの中身を見てみます。
vagrant ssh
で起動したCentOSにアクセスし、ログを確認します。
less /var/log/vboxadd-setup.log
Building the main Guest Additions 6.1.12 module for kernel 4.18.0-193.19.1.el8_2.x86_64.
Error building the module. Build output follows.
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/4.18.0-193.19.1.el8_2.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j1 modules
Makefile:978: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
make: *** [/tmp/vbox.0/Makefile-footer.gmk:117: vboxguest] Error 2
Could not find the X.Org or XFree86 Window System, skipping.
modprobe vboxguest failed
このエラーの中で重要な部分は、
please install libelf-dev, libelf-devel or elfutils-libelf-devel
で、libelf-devなどの依存関係がインストールに失敗するのでなんとかして。ということらしいです。
試しにdnf -y install libelf-dev
としてみると、そんなの無いよと怒られました。
調べてみると、elfutils-libelf-devel
というのに変わっているようなので、これをインストールしてみます。
dnf install -y elfutils-libelf-devel
いったんCentOSから抜けてvagrant reload
を実行します。
これでsync_folderのエラーが解消できました。