Skip to content

Make the build scripts work on FreeBSD#282

Open
lin72h wants to merge 1 commit intoasg017:mainfrom
lin72h:freebsd-core/sqlite-vec
Open

Make the build scripts work on FreeBSD#282
lin72h wants to merge 1 commit intoasg017:mainfrom
lin72h:freebsd-core/sqlite-vec

Conversation

@lin72h
Copy link
Copy Markdown

@lin72h lin72h commented Apr 8, 2026

Summary

This PR makes the touched build scripts and header-generation path work on
FreeBSD without changing the overall release/build structure.

What changed

  • compute version macro parts directly in Makefile
  • fail sqlite-vec.h generation immediately if the version macros are blank
  • switch the touched shell scripts to #!/usr/bin/env bash

Why this matters

On the validated FreeBSD host:

  • the original sqlite-vec.h recipe could generate blank version macros
    because it depended on shell assignment ordering
  • /bin/bash did not exist, even though bash was installed at
    /usr/local/bin/bash

The result was a FreeBSD source-build path that failed for reasons unrelated to
sqlite-vec itself.

Validation

Validated on a real FreeBSD 15.0 amd64 host:

  • gmake clean && rm -f sqlite-vec.h && gmake sqlite-vec.h loadable
  • sqlite3 :memory: ".load ./dist/vec0.so" "select vec_version();"

Known limits

  • the Python test harness was not exercised on this host because the available
    Python 3.11 lacks the stdlib _sqlite3 module

Make the source build less shell-fragile by deriving version macros in make,
failing header generation when the result is blank, and using portable bash
shebangs for the touched scripts.

This preserves the current build flow while making it work on FreeBSD hosts
that do not ship bash at /bin/bash and that expose the make recipe ordering bug.
Copilot AI review requested due to automatic review settings April 8, 2026 01:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the project’s build/release scripts and sqlite-vec.h generation to behave correctly on FreeBSD (notably where bash is not at /bin/bash), while keeping the overall build/release structure unchanged.

Changes:

  • Compute VERSION_MAJOR/MINOR/PATCH directly in the Makefile and pass them into the envsubst-based header generation.
  • Add post-generation checks to fail fast if sqlite-vec.h version macros are blank/invalid.
  • Switch touched shell scripts to #!/usr/bin/env bash and adjust the lint target’s shell selection.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
scripts/vendor.sh Updates shebang to use env bash for FreeBSD compatibility.
scripts/publish-release.sh Updates shebang to use env bash for FreeBSD compatibility.
Makefile Moves version-part parsing into Make variables, validates generated header macros, and adjusts lint shell selection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail xtrace
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set -euo pipefail xtrace does not enable xtrace; it sets the positional parameters to the literal string xtrace (and can break argument handling if this script ever starts using "$@"/"$1"). Use a proper xtrace flag (e.g., include -x in the set options, or enable xtrace in a separate set -x command).

Suggested change
set -euo pipefail xtrace
set -euxo pipefail

Copilot uses AI. Check for mistakes.
black tests/test-loadable.py

lint: SHELL:=/bin/bash
lint: SHELL:=$(shell command -v bash || echo /bin/bash)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint target picks a bash path via command -v bash || echo /bin/bash. If bash exists but isn't on PATH (or if command -v prints nothing), this will fall back to /bin/bash and fail with a confusing "No such file" error on platforms like FreeBSD where bash is typically in /usr/local/bin. Consider making the target fail fast with a clear error when bash can't be located, rather than defaulting to /bin/bash.

Suggested change
lint: SHELL:=$(shell command -v bash || echo /bin/bash)
lint: SHELL:=$(or $(shell command -v bash 2>/dev/null),$(error bash is required for the lint target; please install bash and ensure it is on PATH))

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants