Homebrew / homebrew-core

🍻 Default formulae for the missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
13.68k stars 12.38k forks source link

Libvirt installed by brew is broken #111997

Closed KrystianMarek closed 1 year ago

KrystianMarek commented 2 years ago

brew gist-logs <formula> link OR brew config AND brew doctor output

brew gist-logs

❯ brew gist-logs libvirt
Error: No logs.

brew config

❯ brew config
HOMEBREW_VERSION: 3.6.3
ORIGIN: https://github.com/Homebrew/brew
HEAD: d5b6b068c15a8df60f0f5e34a4ca80dcf82c48e3
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 37544c088d004e90c74c6f49c0be0fc7bedd257a
Core tap last commit: 41 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.gJeWkffLQ1/org.xquartz:0
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 14.0.0 build 1400
Git: 2.37.3 => /opt/homebrew/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.6-arm64
CLT: 14.0.0.0.1.1661618636
Xcode: 14.0.1
Rosetta 2: false

brew doctor

❯ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /opt/homebrew/anaconda3/bin/icu-config
  /opt/homebrew/anaconda3/bin/krb5-config
  /opt/homebrew/anaconda3/bin/freetype-config
  /opt/homebrew/anaconda3/bin/xslt-config
  /opt/homebrew/anaconda3/bin/libpng16-config
  /opt/homebrew/anaconda3/bin/libpng-config
  /opt/homebrew/anaconda3/bin/xml2-config
  /opt/homebrew/anaconda3/bin/python3.9-config
  /opt/homebrew/anaconda3/bin/onig-config
  /opt/homebrew/anaconda3/bin/python3-config
  /opt/homebrew/anaconda3/bin/curl-config
  /opt/homebrew/anaconda3/bin/ncursesw6-config
  /opt/homebrew/anaconda3/bin/pcre2-config

Warning: Broken symlinks were found. Remove them with `brew cleanup`:
  /opt/homebrew/share/man/man5/package-locks.5
  /opt/homebrew/share/man/man5/shrinkwrap-json.5

Verification

What were you trying to do (and why)?

I'm trying to use libvirt

What happened (include all command output)?

Libvirt installes correctly, its service also starts correctly, but libvirt crashes. Brew service is not aware of this.

What did you expect to happen?

I expect libvirt to work. In other words for libvirt to provide qemu:///system or qemu:///session

Step-by-step reproduction instructions (by running brew commands)

brew info libvirt

❯ brew info libvirt
==> libvirt: stable 8.7.0 (bottled), HEAD
C virtualization API
https://libvirt.org/
/opt/homebrew/Cellar/libvirt/8.3.0 (568 files, 38.9MB)
  Built from source
/opt/homebrew/Cellar/libvirt/8.7.0 (580 files, 40.8MB) *
  Poured from bottle on 2022-09-05 at 00:02:59
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libvirt.rb
License: LGPL-2.1-or-later and GPL-2.0-or-later
==> Dependencies
Build: docutils ✘, meson ✘, ninja ✔, perl ✘, pkg-config ✔, python@3.10 ✔, rpcgen ✘
Required: gettext ✔, glib ✔, gnu-sed ✔, gnutls ✔, grep ✔, libgcrypt ✔, libiscsi ✔, libssh2 ✔, yajl ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
To restart libvirt after an upgrade:
  brew services restart libvirt
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/libvirt/sbin/libvirtd -f /opt/homebrew/etc/libvirt/libvirtd.conf
==> Analytics
install: 6,266 (30 days), 17,951 (90 days), 63,104 (365 days)
install-on-request: 4,597 (30 days), 13,306 (90 days), 47,617 (365 days)
build-error: 1 (30 days)

brew services start libvirt

❯ brew services start libvirt
==> Successfully started `libvirt` (label: homebrew.mxcl.libvirt)
❯ brew services info libvirt
libvirt (homebrew.mxcl.libvirt)
Running: ✔
Loaded: ✔
Schedulable: ✘
User: kmarek
PID: 3264

Libvirt process is indeed running

❯ ps aux | grep libvirtd
kmarek            3401   0.0  0.0 408628368   1648 s000  S+    5:02PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox libvirtd
kmarek            3264   0.0  0.0 408677264  12976   ??  S     5:01PM   0:00.03 /opt/homebrew/opt/libvirt/sbin/libvirtd -f /opt/homebrew/etc/libvirt/libvirtd.conf

Stopping the service

❯ brew services stop libvirt
Stopping `libvirt`... (might take a while)
==> Successfully stopped `libvirt` (label: homebrew.mxcl.libvirt)

With libvirtd started from the console, finally I get the error message:

❯ /opt/homebrew/opt/libvirt/sbin/libvirtd -f /opt/homebrew/etc/libvirt/libvirtd.conf
2022-09-29 15:04:42.462+0000: 6169014272: info : libvirt version: 8.7.0
2022-09-29 15:04:42.462+0000: 6169014272: info : hostname: discovery.local
2022-09-29 15:04:42.462+0000: 6169014272: warning : virProcessGetStartTime:1173 : Process start time of pid 3672 not available on this platform
2022-09-29 15:04:42.466+0000: 6169014272: error : virGDBusGetSessionBus:128 : internal error: Unable to get session bus connection: Cannot spawn a message bus without a machine-id: Unable to load /opt/homebrew/var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/opt/homebrew/var/lib/dbus/machine-id”: No such file or directory
2022-09-29 15:04:42.466+0000: 6169014272: error : virGDBusGetSystemBus:101 : internal error: Unable to get system bus connection: Could not connect: No such file or directory
carlocab commented 2 years ago

Does it work if you build the same version from source (ideally with the same configuration) outside of Homebrew?

KrystianMarek commented 2 years ago

No, it does not. Libvirtd compiled from source gives the same error. Since the error is related to dbus, I followed that route and found that dbus on my mac does not work as well

❯ brew services info dbus
dbus (org.freedesktop.dbus-session)
Running: ✘
Loaded: ✔
Schedulable: ✘
❯ /opt/homebrew/Cellar/dbus/1.14.0/bin/dbus-daemon --nofork --session
dbus-daemon[8570]: Failed to start message bus: Check-in failed: No such process
carlocab commented 2 years ago

Thanks for checking. Does dbus work if built from source outside Homebrew (with the same version/configuration)?

KrystianMarek commented 2 years ago

I can't build dbus, there is a miss match in autoconf version.

dbus v1.14.0

❯ ./autogen.sh --no-configure --without-x --disable-dependency-tracking --enable-xml-docs --disable-doxygen-docs
glibtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
glibtoolize: copying file 'build-aux/ltmain.sh'
glibtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
glibtoolize: copying file 'm4/libtool.m4'
glibtoolize: copying file 'm4/ltoptions.m4'
glibtoolize: copying file 'm4/ltsugar.m4'
glibtoolize: copying file 'm4/ltversion.m4'
glibtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:97: installing 'build-aux/compile'
configure.ac:21: installing 'build-aux/missing'
bus/Makefile.am: installing 'build-aux/depcomp'
configure.ac:102: warning: The macro `AC_ISC_POSIX' is obsolete.
configure.ac:102: You should run autoupdate.
./lib/autoconf/specific.m4:550: AC_ISC_POSIX is expanded from...
configure.ac:102: the top level
configure.ac:103: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:103: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:103: the top level
configure.ac:105: warning: The macro `AM_PROG_LIBTOOL' is obsolete.
configure.ac:105: You should run autoupdate.
m4/libtool.m4:101: AM_PROG_LIBTOOL is expanded from...
configure.ac:105: the top level
configure.ac:95: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:162: error: possibly undefined macro: AC_MSG_ERROR
configure.ac:1172: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
configure.ac:1177: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
configure.ac:1186: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
configure.ac:1192: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
autoconf failed - version 2.5x is probably required

autoconf

❯ brew info autoconf
==> autoconf: stable 2.71 (bottled)
Automatic configure script builder
https://www.gnu.org/software/autoconf
/opt/homebrew/Cellar/autoconf/2.71 (71 files, 3.2MB) *
  Poured from bottle on 2022-05-15 at 11:51:08
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/autoconf.rb
License: GPL-3.0-or-later and (GPL-3.0-or-later with Autoconf-exception-3.0)
==> Dependencies
Required: m4 ✔
==> Analytics
install: 153,752 (30 days), 440,620 (90 days), 1,858,537 (365 days)
install-on-request: 21,346 (30 days), 62,321 (90 days), 286,191 (365 days)
build-error: 0 (30 days)

I tried to launch dbus in another way, it runs, but does not produce required /opt/homebrew/var/lib/dbus/machine-id, thus libvirtd still fails.

/opt/homebrew/Cellar/dbus/1.14.0/bin/dbus-daemon --nofork --session --address=unix:path=/opt/homebrew/var/lib/dbus
carlocab commented 2 years ago

Try autoconf@2.69.

KrystianMarek commented 2 years ago
❯ which autoconf
/opt/homebrew/opt/autoconf@2.69/bin/autoconf
❯ ./autogen.sh --no-configure --without-x --disable-dependency-tracking --enable-xml-docs --disable-doxygen-docs
glibtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
glibtoolize: copying file 'build-aux/ltmain.sh'
glibtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
glibtoolize: copying file 'm4/libtool.m4'
glibtoolize: copying file 'm4/ltoptions.m4'
glibtoolize: copying file 'm4/ltsugar.m4'
glibtoolize: copying file 'm4/ltversion.m4'
glibtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:97: installing 'build-aux/compile'
configure.ac:21: installing 'build-aux/missing'
bus/Makefile.am: installing 'build-aux/depcomp'
configure.ac:95: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:162: error: possibly undefined macro: AC_MSG_ERROR
configure.ac:1172: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
configure.ac:1177: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
configure.ac:1186: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
configure.ac:1192: error: Unexpanded AX_ macro found. Please install GNU autoconf-archive
autoconf failed - version 2.5x is probably required
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

rfc6919 commented 1 year ago

@KrystianMarek the machine-id file is meant to be created by dbus-uuidgen in the formula's post_install block

  def post_install
    # Generate D-Bus's UUID for this machine
    system "#{bin}/dbus-uuidgen", "--ensure=#{var}/lib/dbus/machine-id"
  end

what happens if you manually run this:

dbus-uuidgen --ensure=/opt/homebrew/var/lib/dbus/machine-id
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.