Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drizzle-kit@0.21.0 uses @libsql/client, not installed in the workspace #390

Open
hyunbinseo opened this issue May 9, 2024 · 2 comments
Open

Comments

@hyunbinseo
Copy link
Sponsor

hyunbinseo commented May 9, 2024

According to the v0.21.0 release note:

For sqlite dialect, Drizzle will:

  • Check if the @libsql/client driver is installed and use it.
  • If not, try to find better-sqlite3 and use it.
  • If nothing is found, an error will be thrown

There seems to be a resolution error with the pnpm package manager.

Even in a workspace where @libsql/client is not installed as a (dev) dependency,

pnpm why better-sqlite3

# dependencies:
# better-sqlite3 9.6.0
# drizzle-orm 0.30.10
# └── better-sqlite3 9.6.0 peer

pnpm why @libsql/client

# dependencies:
# drizzle-orm 0.30.10
# └── @libsql/client 0.6.0 peer

The drizzle-kit commands (e.g. migrate, studio) finds it and uses it instead.

LibsqlError: URL_INVALID: The URL is not in a valid format
    at parseUri (file:///path-to-workspace/node_modules/.pnpm/@libsql+core@0.6.0/node_modules/@libsql/core/lib-esm/uri.js:9:15)

Ability to specify the better-sqlite3 driver is no longer available.

@AlexBlokh
Copy link
Contributor

it might not be in dependencies in package.json, but still be in node modules, I suppose if you delete node modules and install again - it should work just fine

@hyunbinseo
Copy link
Sponsor Author

hyunbinseo commented May 10, 2024

Finally found a reproduction:

pnpm -v # 9.1.0

pnpm i drizzle-orm @libsql/client -D
# devDependencies:
# + @libsql/client 0.6.0
# + drizzle-orm 0.30.10

pnpm rm @libsql/client
# devDependencies:
# - @libsql/client 0.6.0

rm -rf node_modules

pnpm i --force
# devDependencies:
# + drizzle-orm 0.30.10

The node_modules/.pnpm/@libsql+client@0.6.0 directory persists.

# pnpm-lock.yaml

lockfileVersion: '9.0'

settings:
  autoInstallPeers: true
  excludeLinksFromLockfile: false

importers:

  .:
    devDependencies:
      drizzle-orm:
        specifier: ^0.30.10
        version: 0.30.10(@libsql/client@0.6.0)

packages:

  '@libsql/client@0.6.0':
    resolution: {integrity: sha512-qhQzTG/y2IEVbL3+9PULDvlQFWJ/RnjFXECr/Nc3nRngGiiMysDaOV5VUzYk7DulUX98EA4wi+z3FspKrUplUA==}

The workaround is to:

  • uninstall and reinstall drizzle-orm dependency
  • remove node_modules and reinstall dependencies
pnpm rm drizzle-orm
pnpm i drizzle-orm -D
# Update pnpm lockfile
# pnpm-lock.yaml

importers:

  .:
    devDependencies:
      drizzle-orm:
        specifier: ^0.30.10
        version: 0.30.10
rm -rf node_modules
pnpm i --force

For pnpm monorepo,

  • uninstall and reinstall drizzle-orm dependency from the nested directory
  • remove workspace root node_modules and reinstall dependencies recursively

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

No branches or pull requests

2 participants