libusb icon indicating copy to clipboard operation
libusb copied to clipboard

libusb_init() fails with Other error [-99] if in chroot and --disable-udev

Open fabled opened this issue 6 years ago • 10 comments

I am getting:

Failed to get USB context: failed to init libusb: Other error [-99] (g-usb-context-error-quark, 0)

When running in chroot where /dev/bus/usb is empty. Apparently no error is given if udev is being used.

I would like to clarify if libusb_init is expected to succeed even if no USB bus is present. And to have consistent behavior regardless of if using --disable-udev or --enable-udev.

For background, see: https://github.com/hughsie/fwupd/issues/1219

fabled avatar Jul 16 '19 10:07 fabled

It is better to ask in the libusb-devel mailing list for questions.

mcuee avatar Jul 30 '19 03:07 mcuee

Please use libusb mailing list. Thanks.

mcuee avatar Dec 07 '19 05:12 mcuee

Why was this bug report closed? I'm here two years later, trying to figure out why I am getting "Fu-WARNING **: FuMain: failed to get USB context: failed to init libusb: Other error [-99]" errors and there is ZERO information here about this libusb bug or its resolution. I have non-USB devices requiring firmware updates to work correctly and libusb is a showstopper for me. "Use the mailing list" is absolutely useless resolution information.

fuzzyeric avatar Jul 13 '21 20:07 fuzzyeric

Good point. Apparently this ticket was closed wrongly (Edit to add: without properly mentioning the reasoning).

Whether this is an issue that is another story.

Personally I did not think it is an issue at the time. And I still think it is not a real issue for libusb now. If there is no USB controller present, I think there is nothing wrong for libusb to fail libusb_init.

But I will let other libusb admins and contributors to chime in for their opinions.

mcuee avatar Jul 13 '21 22:07 mcuee

Please also refer to past issue #511.

When the container does not support libudev (--disable-udev) and Netlink, libusb_init() will fail.

For that ticket, we improved the codes but it will not change that libusb_init will fail in that situation. https://github.com/libusb/libusb/commit/a5624b22267ec0e146825d3fe94d9e4b2f5ae503

mcuee avatar Jul 13 '21 22:07 mcuee

@fuzzyeric And also I do not understand why this becomes a showstopper for you in fwupd since you are using non-USB device and that libusb_init failing is just an warning for the application. I assume it has other codes to deal with non USB devices.

mcuee avatar Jul 13 '21 22:07 mcuee

On the other hand, there is a potential useful enhancement to libusb here. But the author has closed the pull-request. Maybe you can take a look whether it is useful info or not. https://github.com/libusb/libusb/pull/559

It mentioned the following. https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/NCS2-in-docker-container-on-RPI-results-in-RuntimeError-Can-not/m-p/1191905/highlight/true#M19803

mcuee avatar Jul 13 '21 22:07 mcuee

IMHO even if we don't document it I expect libusb_init may fail if no USB bus exists. This is not a libusb bug.

hjelmn avatar Jul 14 '21 00:07 hjelmn

I will see about updating the documentation if needed.

hjelmn avatar Jul 14 '21 00:07 hjelmn

One the issue raised in https://github.com/fwupd/fwupd/issues/1219 is that libusb_init() error codes are not well documented.

mcuee avatar Jul 14 '21 09:07 mcuee