ethanniser / the-beth-stack

An opinionated hypermedia-driven architecture for building web apps
MIT License
848 stars 81 forks source link

401 when connecting to Turso #2

Closed RomanADavis closed 1 year ago

RomanADavis commented 1 year ago

When I try to run the script, it says "bunx: command not found."

This itself is workaroundable, just use "bun x," so, "bun x drizzle-kit push:sqlite," but this itself leads to:

[5.18ms] ".env"
No config path provided, using default 'drizzle.config.ts'
Reading config file '/mnt/c/Users/Roman/code/beth-stack/drizzle.config.ts'
drizzle-kit: v0.19.9
drizzle-orm: v0.27.2

43219 |       code;
43220 |       constructor(message, code, cause) {
43221 |         if (code !== void 0) {
43222 |           message = `${code}: ${message}`;
43223 |         }
43224 |         super(message, { cause });
            ^
LibsqlError: HRANA_WEBSOCKET_ERROR: Unexpected server response: 401
 code: "HRANA_WEBSOCKET_ERROR"

      at new LibsqlError (/mnt/c/Users/Roman/code/beth-stack/node_modules/drizzle-kit/index.cjs:43224:8)
      at mapHranaError (/mnt/c/Users/Roman/code/beth-stack/node_modules/drizzle-kit/index.cjs:48336:11)
      at /mnt/c/Users/Roman/code/beth-stack/node_modules/drizzle-kit/index.cjs:48470:16
turso db show beth-stack-db
Name:           beth-stack-db
URL:            libsql://beth-stack-db-romanadavis.turso.io
ID:             96a9f76f-2718-11ee-b4f9-e6df71830bc6
Locations:      fra
Size:           12 kB

Database Instances:
NAME                  TYPE        LOCATION 
possible-starfire     primary     fra        

and

turso db tokens create beth-stack-db
eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2ODk5MjU1MzMsImlkIjoiOTZhOWY3NmYtMjcxOC0xMWVlLWI0ZjktZTZkZjcxODMwYmM2In0.-NgC4fK_WXVMHFm5t94MU_qgI8im6tRLtrQPHRDorwMNAdAnoPwDauuQVGSwQZRbqhODuOnnc3nBJJHQ0kmaCg

give me

DATABASE_URL="libsql://beth-stack-db-romanadavis.turso.io"
DATABASE_AUTH_TOKEN="eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2ODk5MjU1MzMsImlkIjoiOTZhOWY3NmYtMjcxOC0xMWVlLWI0ZjktZTZkZjcxODMwYmM2In0.-NgC4fK_WXVMHFm5t94MU_qgI8im6tRLtrQPHRDorwMNAdAnoPwDauuQVGSwQZRbqhODuOnnc3nBJJHQ0kmaCg"

I've tried with and without quotes. Any ideas?

ethanniser commented 1 year ago

hm bun x and bunx are identical there is an open issue on the bun repo for bunx to not be installed

I actually had this same issue at first and fly.io hotfixed their cli for me

for me when I reinstalled bun (just ran the curl script again) the next day bunx magically appeared like it should

but if its not working with bun x than the issue is somewhere else


I just loaded your environment variables into my project (didnt do anything to your db just checked if drizzle would prompt me to go ahead with the schema changes) and both bunx and bun x worked fine

maybe its a dependency issue?

here is my package.json

{
  "name": "the-beth-stack",
  "module": "src/index.tsx",
  "type": "module",
  "scripts": {
    "db:push": "bunx drizzle-kit push:sqlite",
    "db:studio": "bunx drizzle-kit studio",
    "dev": "bun run --watch src/index.tsx"
  },
  "devDependencies": {
    "@flydotio/dockerfile": "latest",
    "bun-types": "latest",
    "drizzle-kit": "^0.19.6",
    "typed-html": "^3.0.1"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@elysiajs/html": "^0.5.2",
    "@libsql/client": "^0.3.0",
    "drizzle-orm": "^0.27.2",
    "elysia": "^0.5.22",
    "twind": "^0.16.19"
  }
}
RomanADavis commented 1 year ago

I downloaded the zip, and tried to run the script to reduce the chance that some change I had made had made the code inoperable.

I went and ran the curl script. Got a slightly different error.

bun run db:push
$ bunx drizzle-kit push:sqlite
/bin/bash: bunx: command not found
error: script "db:push" exited with code 127

Tried reinstalling, but no changes

bun install
[3.86ms] ".env"
bun install v0.6.14 (b5665739)

Checked 239 installs across 278 packages (no changes) [2.53s]

Dependencies should be the same as in the main branch on github:

{
  "name": "the-beth-stack",
  "module": "src/index.tsx",
  "type": "module",
  "scripts": {
    "db:push": "bunx drizzle-kit push:sqlite",
    "db:studio": "bunx drizzle-kit studio",
    "dev": "concurrently \"bun run --watch src/index.tsx\" \"bun run tw:dev\"",
    "tw": "bunx tailwindcss -i ./src/styles.css -o ./tailwind-gen/styles.css",
    "tw:dev": "bunx tailwindcss -i ./src/styles.css -o ./tailwind-gen/styles.css --watch"
  },
  "devDependencies": {
    "@flydotio/dockerfile": "latest",
    "bun-types": "latest",
    "concurrently": "^8.2.0",
    "drizzle-kit": "^0.19.6",
    "tailwindcss": "^3.3.3",
    "typed-html": "^3.0.1"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@elysiajs/html": "^0.5.2",
    "@libsql/client": "^0.3.0",
    "drizzle-orm": "^0.27.2",
    "elysia": "^0.5.22"
  }
}
ethanniser commented 1 year ago

and then same error as before if you use bun x instead of bunx?

RomanADavis commented 1 year ago

Slightly different, but effectively the same; says that bunx was not found. The error for running bun x drizzle-kit push:sqlite is:

bun x drizzle-kit push:sqlite
[3.74ms] ".env"
No config path provided, using default 'drizzle.config.ts'
Reading config file '/mnt/c/Users/Roman/code/the-beth-stack-main/drizzle.config.ts'
drizzle-kit: v0.19.6
drizzle-orm: v0.27.2

37869 |       code;
37870 |       constructor(message, code, cause) {
37871 |         if (code !== void 0) {
37872 |           message = `${code}: ${message}`;
37873 |         }
37874 |         super(message, { cause });
            ^
LibsqlError: HRANA_WEBSOCKET_ERROR: Unexpected server response: 401
 code: "HRANA_WEBSOCKET_ERROR"

      at new LibsqlError (/mnt/c/Users/Roman/code/the-beth-stack-main/node_modules/drizzle-kit/index.cjs:37874:8)
      at mapHranaError (/mnt/c/Users/Roman/code/the-beth-stack-main/node_modules/drizzle-kit/index.cjs:42986:11)
      at /mnt/c/Users/Roman/code/the-beth-stack-main/node_modules/drizzle-kit/index.cjs:43120:16
RomanADavis commented 1 year ago

Idea: Maybe I should update WSL. It's been a while. Trying that next.

EDIT: Whelp, nevermind.

wsl --update
Checking for updates.
The most recent version of Windows Subsystem for Linux is already installed.
ethanniser commented 1 year ago

I don't think its a drizzle-kit or turso issue just because of the fact that it worked fine on my machine, but it may be worth asking in their respective discords (turso, drizzle)

RomanADavis commented 1 year ago

Currently seeing about how I could completely delete wsl and reinstall everything. If that doesn't work, then I'll go complain to those guys. Thanks.

ethanniser commented 1 year ago

Sounds good. I’m going to close this for now, but feel free to reopen if there something in this repo that can be improved.

RomanADavis commented 1 year ago

Idea: What version of bun are you using?

bun --version
0.6.14
ethanniser commented 1 year ago

I was on 0.6.14 as well. Although 0.7.0 just dropped may upgrading will help?

arjunindia commented 1 year ago

+1 I do have bunx working, but getting the websocket error. For me it's actually a 404

arjunindia commented 1 year ago

Seems like libsql client was not tested with bun, and could cause websocket/platform errors?

pauloprojject commented 1 year ago

+1 I do have bunx working, but getting the websocket error. For me it's actually a 404

i'm having the same issue, maybe newer versions of bun is not working properly?