After some digging I found out that the ss utility is not supported on MacOS. I even tried adding the nix package utility iproute2 which includes it but I got a warning in regards to installing unsupported utilities. My 2c it's probably easier to check if on darwin and use netstat on the script that checks for available ports.
I tested on my local machine and it worked by replacing it with netstat
#!/nix/store/60qp4q78hlg1fsvq4np6iv0gpqrl4v4p-bash-5.2p26/bin/bash
set -eo pipefail
# Utility function to return a random open port
# Get a list of all used ports
USED_PORTS=$(netstat -tan | awk 'NR>1 {print $4}' | awk -F':' '{print $NF}' | sort -n | uniq)
# Search for a free PORT by checking against the list of used ports
START_PORT=$((RANDOM % 9001 + 1024))
for PORT in $(seq $START_PORT $((START_PORT + 100)) | shuf); do
if ! echo "$USED_PORTS" | grep -q "^$PORT$"; then
echo "$PORT"
break
fi
done
Steps to Reproduce
On a MacOS machine try the buildkit steps.
Version
main (development branch)
Relevant log output
/nix/store/hsqws7fqngrv8fb8b6mr2ikvmw8cqfwq-pf-get-open-port/bin/pf-get-open-port: line 8: ss: command not found
Closing build processes...
Prior Search
What happened?
I was trying to run
pf-buildkit-build --repo=test --tag=dev --context=. --file=./Dockerfile
following the guide https://panfactum.com/docs/edge/guides/addons/buildkit/installing on the edge.24-07-03 release.After some digging I found out that the
ss
utility is not supported on MacOS. I even tried adding the nix package utility iproute2 which includes it but I got a warning in regards to installing unsupported utilities. My 2c it's probably easier to check if on darwin and use netstat on the script that checks for available ports.I tested on my local machine and it worked by replacing it with netstat
Steps to Reproduce
On a MacOS machine try the buildkit steps.
Version
main (development branch)
Relevant log output