Open jacksonattwood opened 1 month ago
Regarding nut-scanner
library search and MacOS (two separate problems that happened to intersect), this was recently addressed in a series of PRs merged to master
branch, so the solution would be part of a next release. For more details, you can trawl the labels assigned to this issue.
If you are able to build NUT, you can give it a shot roughly following the instructions at https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests
So far there was little recent feed-back from the MacOS community, so I can only reflect on a limited experience with VMs provided by CI farms, where HomeBrew packaging is used - and their tooling sufficed to get NUT built and pass CI tests.
As for the failed driver start-up, for a quick test try -u root
on command line (or user=root
in ups.conf
), my first guess would be that the run-time user account (Succeeded to become_user(_nut): now UID=504 GID=502
) does not have permissions to the device filesystem node for the USB entity. NUT sources do generate files with lists of USB vendor and product ID pairs for several platforms that automate permissions assignment (udev, upower, devd, etc.) but I am not sure if any of those is available on MacOS and/or in the delivered packages. If the devfs and your connection (USB port) are persistent, maybe a chown
of the devfs node would help. If they are volatile but at least same-named across reboots, an init script (launchd manifest independent of logged-in session, running as root) is a next-best option. Not off the table is running the NUT driver as root
if it helps...
A second guess would be that someone else (kernel or program, possibly virtualization pass-through) got to handle the device first, especially as it is classed as a HID device (so maybe generic kernel handler for HID). The permissions assignment solutions noted above usually cover this part too (which handler to auto-launch, if any).
If you are able to build NUT, you can give it a shot roughly following the instructions at https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests
This is the first thing I tried, however as soon as it tries to make
, it throws heaps of errors and exits:
./ci_build.sh: configure phase complete (0)
Configuration finished, starting make
For parallel builds, '-j 24 -l 96.0' options would be used
Making all in include
NUT_VERSION: "2.8.2-726-g95e2d98c1"
test -f "nut_version.h" || cp "nut_version.h.tmp" "nut_version.h"
cmp -s "nut_version.h.tmp" "nut_version.h" || cp "nut_version.h.tmp" "nut_version.h"
rm -f "nut_version.h.tmp"
make all-am
make[2]: Nothing to be done for `all-am'.
Making all in common
make all-am
CC parseconf.lo
CC libcommon_la-state.lo
CC libcommon_la-upsconf.lo
CC libcommon_la-str.lo
CC libcommon_la-common.lo
CC libcommonclient_la-str.lo
CC libcommonclient_la-state.lo
CC libcommonclient_la-common.lo
CXX libnutconf_la-nutconf.lo
CXX libnutconf_la-nutwriter.lo
CXX libnutconf_la-nutstream.lo
CXX libnutconf_la-nutipc.lo
CC libcommonstr_la-str.lo
CC libcommonstr_la-common.lo
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
2 errors generated.
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
make[2]: *** [libcommonstr_la-str.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [libcommon_la-str.lo] Error 1
2 errors generated.
2 errors generated.
make[2]: *** [parseconf.lo] Error 1
2 errors generated.
2 errors generated.
make[2]: *** [libcommonclient_la-str.lo] Error 1
2 errors generated.
make[2]: *** [libcommon_la-upsconf.lo] Error 1
make[2]: *** [libcommonclient_la-state.lo] Error 1
make[2]: *** [libcommon_la-state.lo] Error 1
2 errors generated.
2 errors generated.
make[2]: *** [libcommonclient_la-common.lo] Error 1
make[2]: *** [libcommonstr_la-common.lo] Error 1
2 errors generated.
make[2]: *** [libcommon_la-common.lo] Error 1
2 errors generated.
2 errors generated.
make[2]: *** [libnutconf_la-nutipc.lo] Error 1
make[2]: *** [libnutconf_la-nutstream.lo] Error 1
2 errors generated.
make[2]: *** [libnutconf_la-nutwriter.lo] Error 1
2 errors generated.
make[2]: *** [libnutconf_la-nutconf.lo] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1
As for the failed driver start-up, for a quick test try
-u root
on command line (oruser=root
inups.conf
)
So, I added user = root
to the config, and that lets the driver run perfectly fine:
jacksonattwood@motioneye etc % sudo /opt/local/bin/usbhid-ups -DD -a OFFICE
Network UPS Tools - Generic HID driver 0.53 (2.8.2)
USB communication driver (libusb 1.0) 0.47
0.000000 [D1] upsdrv_makevartable...
0.000032 [D1] Using USB implementation: libusb-1.0.27 (API: 0x100010a)
0.000379 [D1] testval_reloadable: setting 'user' exists and differs: new value 'root' vs. '_nut'
0.000387 [D1] Overriding previously specified user '_nut' with 'root' specified for driver section
0.000397 [D1] Network UPS Tools version 2.8.2 (release/snapshot of 2.8.2) built with Apple clang version 14.0.3 (clang-1403.0.22.14.1); Target: x86_64-apple-darwin22.6.0; Thread model: posix and configured with flags: --prefix=/opt/local --with-serial=no --with-usb=auto --with-snmp=no --with-hal=auto --with-cgi=no --with-neonxml=no --with-ssl=yes --with-ipv6=no --with-statepath=/opt/local/var/db/ups --with-pidpath=/opt/local/var/run --with-hotplug-dir=/opt/local/etc/nut/hotplug --with-udev-dir=/opt/local/etc/nut/udev --with-user=_nut --with-group=_nut
0.000401 [D1] debug level is '2'
0.002502 [D1] Succeeded to become_user(root): now UID=0 GID=0
0.002541 [D1] upsdrv_initups (non-SHUT)...
0.002545 [D2] Initializing an USB-connected UPS with library libusb-1.0.27 (API: 0x100010a) (NUT subdriver name='USB communication driver (libusb 1.0)' ver='0.47')
0.011778 [D2] Checking device 1 of 3 (0764/0501)
0.013199 [D2] - VendorID: 0764
0.013206 [D2] - ProductID: 0501
0.013209 [D2] - Manufacturer: CPS
0.013211 [D2] - Product: BR1000ELCD
0.013213 [D2] - Serial Number: unknown
0.013214 [D2] - Bus: 020
0.013216 [D2] - Bus Port: 006
0.013219 [D2] - Device: 007
0.013221 [D2] - Device release number: 0001
0.013223 [D2] Trying to match device
0.013229 [D2] match_function_subdriver (non-SHUT mode): matching a device...
0.013240 [D2] Device matches
0.013242 [D2] Reading configuration descriptor 1 of 1
0.013317 [D2] successfully set kernel driver auto-detach flag
0.014471 [D2] Claimed interface 0 successfully
0.015477 [D2] Retrieved HID descriptor (expected 9, got 9)
0.015491 [D2] HID descriptor length 562
0.035607 [D2] Report Descriptor size = 562
0.035688 Using subdriver: CyberPower HID 0.80
0.035695 [D1] 67 HID objects found
0.036504 [D1] Path: UPS.PowerSummary.iProduct, Type: Feature, ReportID: 0x1d, Offset: 0, Size: 8, Value: 1
0.037140 [D1] Path: UPS.PowerSummary.iManufacturer, Type: Feature, ReportID: 0x03, Offset: 0, Size: 8, Value: 3
0.037149 [D1] Path: UPS.PowerSummary.iOEMInformation, Type: Feature, ReportID: 0x03, Offset: 8, Size: 8, Value: 7
0.037812 [D1] Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, ReportID: 0x04, Offset: 0, Size: 8, Value: 4
0.038554 [D1] Path: UPS.PowerSummary.ff0100d0, Type: Feature, ReportID: 0x1e, Offset: 0, Size: 8, Value: 5
This keeps going, updating every 1.5-2 seconds as it should...
However, when launching upsd
as sudo, I get this:
jacksonattwood@motioneye etc % sudo upsd
Network UPS Tools upsd 2.8.2
fopen /opt/local/var/db/ups/upsd.pid: No such file or directory
Could not find PID file '/opt/local/var/db/ups/upsd.pid' to see if previous upsd instance is already running!
/opt/local/etc/upsd.conf is world readable
listening on 0.0.0.0 port 3493
Can't connect to UPS [OFFICE] (usbhid-ups-OFFICE): No such file or directory
Found 1 UPS defined in ups.conf
/opt/local/etc/upsd.users is world readable
jacksonattwood@motioneye etc %
If it helps, here's my ups.conf
[OFFICE]
driver = usbhid-ups
port = auto
desc = "Office UPS"
vendorid = "0764*"
user = root
A second guess would be that someone else (kernel or program, possibly virtualization pass-through) got to handle the device first, especially as it is classed as a HID device (so maybe generic kernel handler for HID). The permissions assignment solutions noted above usually cover this part too (which handler to auto-launch, if any).
Interesting to know, Virtualbox always fails to claim ownership of the device, so I can't passthrough to my Ubuntu VM
Regarding the warnings: did you export a HOMEBREW_PREFIX
to let ci_build.sh
fit that build system? For example,
eval "$(brew shellenv)"
should do it.
At worst, specifically and clumsily:
HOMEBREW_PREFIX="`brew config | grep HOMEBREW_PREFIX: | awk '{print $2}'`"
Updating the wiki and in-source docs to clarify this bit :)
Regarding the warnings: did you export a
HOMEBREW_PREFIX
to letci_build.sh
fit that build system? For example,eval "$(brew shellenv)"
So that didn't do it :(
At worst, specifically and clumsily:
HOMEBREW_PREFIX="`brew config | grep HOMEBREW_PREFIX: | awk '{print $2}'`"
Mighty unfortunate news is that trying both of those return the same error:
Making all in common
make all-am
CC parseconf.lo
CC libcommon_la-state.lo
CC libcommon_la-str.lo
CC libcommon_la-upsconf.lo
CC libcommonclient_la-state.lo
CC libcommon_la-common.lo
CC libcommonclient_la-str.lo
CC libcommonclient_la-common.lo
CXX libnutconf_la-nutconf.lo
CXX libnutconf_la-nutstream.lo
CXX libnutconf_la-nutwriter.lo
CXX libnutconf_la-nutipc.lo
CC libcommonstr_la-str.lo
CC libcommonstr_la-common.lo
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libcommon_la-str.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [libcommonstr_la-str.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libcommonclient_la-str.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libcommon_la-state.lo] Error 1
make[2]: *** [libcommon_la-upsconf.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [parseconf.lo] Error 1
make[2]: *** [libcommonclient_la-state.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libcommon_la-common.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libcommonclient_la-common.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libcommonstr_la-common.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libnutconf_la-nutstream.lo] Error 1
make[2]: *** [libnutconf_la-nutipc.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libnutconf_la-nutwriter.lo] Error 1
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
2 errors generated.
make[2]: *** [libnutconf_la-nutconf.lo] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1
Did you fully re-run ci_build.sh
after setting the environment? Try also rm -f configure Makefile
before such re-running, to make sure brew'ed packages are taken into account at all steps of the way (e.g. when generating the configure
script).
So what I was doing before was removing the entire repo, then cloning into it again and trying again. I've tried:
./ci_build.sh
sudo ./ci_build.sh
./ci_build.sh inplace
sudo ./ci_build.sh inplace
However, none of these have changed the error at all.
Even stranger, then... Maybe something else should be detected for auto-magic and is not.
You can try to pre-export CFLAGS with the anti-warning values set in the script, at least... For inspiration, see :
UPDATE: While preparing the reference for this writing, I realized these tunings only take place with BUILD_TYPE=...
for a number of patterns listed at https://github.com/networkupstools/nut/blob/88fdc820a04c0fcdae88beddf7d72a6f0af5be4b/ci_build.sh#L827 -- but not for the most-default build (no BUILD_TYPE
at all) that can be set up by the developer to their liking (or must, as is the case here) or an in-place build. The whole situation is recent and was addressed for CI primarily, based on existing script layout in that block and on known build agent environments :-}
So one way forward is to both ensure the HOMEBREW_PREFIX
and BUILD_TYPE
, e.g.:
:; HOMEBREW_PREFIX=/usr/local BUILD_TYPE=default CI_REQUIRE_GOOD_GITIGNORE="false" DO_CLEAN_CHECK=no ./ci_build.sh
Another may be to take the classic approach and piece together the ./configure
parameters explicitly on command line (taking inspiration from the ci_build.sh
script liberally)...
MacOS Ventura | NUT v. 2.8.2 from MacPorts
When trying to run
sudo nut-scanner -DDDDDD -C > /tmp/nutscan.log 2>&1
on MacOS Ventura (installed via macports) I get the following output:FYI I am able to launch upsd and upsmon, both of which are up to date. No matter what, upsd reports back that it cannot connect to the ups:
After running
sudo /opt/local/bin/usbhid-ups -DD -a OFFICE