Skip to content

Commit 31a73e1

Browse files
committed
fix(drivers): make empty-root diagnostic precise
1 parent 118fb84 commit 31a73e1

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎packages/drivers/src/resolve.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,13 @@ export class DriverNotInstalledError extends Error {
9292
constructor(driver: DriverName, packages: readonly string[], searched: readonly string[]) {
9393
const label = DRIVER_LABELS[driver]
9494
const installDir = driverInstallDir()
95-
// `driverSearchRoots()` only returns directories that exist, so on a machine
96-
// that has never installed a driver it returns nothing at all — the normal
97-
// first-run state, given drivers are deliberately not shipped. That left the
98-
// message ending in a bare "Searched 0 locations:" with nothing after the
99-
// colon, which names nowhere and reads like a bug. Say plainly that there was
100-
// nothing to search, and name the directory the install command creates.
95+
// `driverSearchRoots()` only returns directories that exist, so a compiled
96+
// first run can have no searchable roots at all. The old message then ended
97+
// in a bare "Searched 0 locations:" with nothing after the colon. Describe
98+
// only what the empty list proves and name the managed location users need.
10199
const searchedLine = searched.length
102100
? `Searched ${searched.length} location${searched.length === 1 ? "" : "s"}: ${searched.join(", ")}`
103-
: `Searched nothing: no driver directory exists yet, not even ${path.join(installDir, "node_modules")}.`
101+
: `No searchable driver locations were found. Expected managed location: ${path.join(installDir, "node_modules")}.`
104102
super(
105103
`${label} driver not installed.\n` +
106104
`Install it with the warehouse_install_driver tool, or run:\n` +

‎packages/drivers/test/resolve-unit.test.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,16 +826,18 @@ describe("manual-install hints are copy-pasteable", () => {
826826
expect(prefix!.startsWith("'") || prefix!.startsWith('"')).toBe(true)
827827
})
828828

829-
test("DriverNotInstalledError names a location when nothing was searched", () => {
830-
process.env["ALTIMATE_DRIVER_DIR"] = path.join(path.sep, "tmp", "altimate-drivers-absent")
829+
test("DriverNotInstalledError names a location for an empty searched list", () => {
830+
const installDir = path.join(tmpRoot, "absent")
831+
process.env["ALTIMATE_DRIVER_DIR"] = installDir
831832

832-
// The first-run state: no driver directory exists, so driverSearchRoots()
833-
// returns nothing. The message must still name somewhere.
833+
// Model the possible empty-root result directly. A unit-test checkout has
834+
// legitimate executable/package roots, so forcing driverSearchRoots() to
835+
// return [] here would be host-dependent.
834836
const err = new DriverNotInstalledError("duckdb", DRIVER_PACKAGES.duckdb, [])
835837

836838
expect(err.message).not.toContain("Searched 0 locations:")
837-
expect(err.message).toContain("Searched nothing")
838-
expect(err.message).toContain(path.join("altimate-drivers-absent", "node_modules"))
839+
expect(err.message).toContain("No searchable driver locations were found.")
840+
expect(err.message).toContain(`Expected managed location: ${path.join(installDir, "node_modules")}.`)
839841
// Still distinguishable from a broken install, and still actionable.
840842
expect(err.message).toContain("DuckDB driver not installed.")
841843
expect(err.message).toContain("npm install --prefix")

0 commit comments

Comments
 (0)