aradzie / keybr.com

The smartest way to learn touch typing and improve your typing speed.
https://www.keybr.com/
GNU Affero General Public License v3.0
1.96k stars 176 forks source link

500 - Internal Server Error #148

Closed Ottaviocr closed 8 months ago

Ottaviocr commented 8 months ago

My system is Debian Bullseye, I have cloned the git repo and followed the instructions religiously from getting_started.md.

Then, upon running npm start, I get:

oc@t440:~/git/keybr.com$ npm start

> keybr.com@0.0.0 start
> env NODE_ENV=development node --enable-source-maps ./root/index.js

2024-03-04T14:46:07.553Z DEBUG: Probe dotenv file '/home/oc/git/keybr.com/.env.development'
2024-03-04T14:46:07.556Z DEBUG: Probe dotenv file '/home/oc/git/keybr.com/.env'
2024-03-04T14:46:07.556Z DEBUG: Probe dotenv file '/etc/keybr/env.development'
2024-03-04T14:46:07.556Z DEBUG: Probe dotenv file '/etc/keybr/env'
2024-03-04T14:46:07.557Z INFO: Loaded dotenv file '/etc/keybr/env'
2024-03-04T14:46:07.574Z INFO: Configuration {
  dataDir: '/home/oc/.local/state/keybr',
  publicDir: '/home/oc/keybr.com/root/public',
  canonicalUrl: 'http://localhost:3000/'
}
2024-03-04T14:46:07.635Z INFO: Worker started { pid: 24699 }
2024-03-04T14:46:07.640Z INFO: Worker started { pid: 24700 }
2024-03-04T14:46:07.667Z INFO: Worker started { pid: 24713 }
2024-03-04T14:46:07.716Z INFO: Worker started { pid: 24706 }
2024-03-04T14:46:07.724Z INFO: Worker started { pid: 24712 }
2024-03-04T14:46:09.145Z INFO: Server started { pid: 24700, port: 3000, username: 'oc' }
2024-03-04T14:46:09.213Z INFO: Server started { pid: 24713, port: 3001, username: 'oc' }
2024-03-04T14:46:09.265Z INFO: Server started { pid: 24699, port: 3000, username: 'oc' }
2024-03-04T14:46:09.334Z INFO: Server started { pid: 24706, port: 3000, username: 'oc' }
2024-03-04T14:46:09.388Z INFO: Server started { pid: 24712, port: 3000, username: 'oc' }
Error: ENOENT: no such file or directory, open '/home/oc/keybr.com/root/public/assets/manifest.json'
    at Object.openSync (node:fs:596:3)
    at readFileSync (node:fs:464:35)
    at loadManifestSync (webpack://keybr.com/packages/keybr-assets/lib/load.ts:11:31)
    at ManifestModule.provideManifest (webpack://keybr.com/packages/server/lib/app/assets/module.ts:10:28)
    at makeValue (webpack://keybr.com/node_modules/@fastr/invert/src/impl/binding/provider.ts:14:22)
    at ProviderBinding.getValue (webpack://keybr.com/node_modules/@fastr/invert/src/impl/binding/provider.ts:19:31)
    at Container.get (webpack://keybr.com/node_modules/@fastr/invert/src/container.ts:77:22)
    at Container.get (webpack://keybr.com/node_modules/@fastr/invert/src/container.ts:80:27)
    at <anonymous> (webpack://keybr.com/node_modules/@fastr/invert/src/impl/util.ts:22:47)
    at Array.map (<anonymous>) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/oc/keybr.com/root/public/assets/manifest.json'
}

If I manually point my browser to http://localhost:3000/, I get "500 - Internal Server Error" error

Where would I get this "manifest.json" from?

Ottaviocr commented 8 months ago

I forgot to add, I had an error during "run compile":


Running /home/oc/opt/bin/npm run compile, pid: 28370

> @keybr/keyboard@0.0.0 compile
> tsc

lib/data/layout/fr_erglace.ts(8,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
  Source has 5 element(s) but target allows only 4.
lib/data/layout/fr_erglace.ts(9,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(10,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(11,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(12,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(13,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(14,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(15,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(16,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(17,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(22,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(24,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(25,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(27,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(28,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(34,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(35,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(37,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(39,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(40,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(41,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(42,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(50,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(51,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
lib/data/layout/fr_erglace.ts(52,3): error TS2322: Type '[number, number, number, number, number]' is not assignable to type 'readonly [a?: number | undefined, b?: number | undefined, c?: number | undefined, d?: number | undefined]'.
npm ERR! Lifecycle script `compile` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @keybr/keyboard@0.0.0 
npm ERR!   at location: /home/oc/git/keybr.com/packages/keybr-keyboard 
Error: NPM Script Runner: /home/oc/opt/bin/npm run compile exited with code 1

┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
Took a total of 1m 16.66s to complete. 
aradzie commented 8 months ago

The last compilation error has been fixed in the latest commits just a couple hours ago.

aradzie commented 8 months ago

The manifest.json file is produced by webpack when running the npm run build script. Can you please check that file /home/oc/keybr.com/root/public/assets/manifest.json exists?

To solve the Internal Server Error you need to fix the PUBLIC_DIR configuration variable in your .env file. In your case it should be something like PUBLIC_DIR=~/keybr.com/root/public. However, looking at the error message, it looks like you configured it correctly.

Please check the existence of the manifest file.

aradzie commented 8 months ago

Ah, from the first log line I can see that you checked out the repository to ~/git/keybr.com.

oc@t440:~/git/keybr.com$ npm start

However, later in the log I see that your public dir is configured as ~/keybr.com:

  ...
  publicDir: '/home/oc/keybr.com/root/public',
  ...

That is a different directory!

Please update the PUBLIC_DIR variable your .env file:

PUBLIC_DIR=~/git/keybr.com/root/public

Mind the /git/ prefix.

Ottaviocr commented 8 months ago

Thanks aradzie, that fixes it.

(Incidentally, is there a way to import the settings from my online instance at keybr.com?)

aradzie commented 8 months ago

If you want to import your data from keybr.com, you can download the file loaded from the https://www.keybr.com/_/sync/data endpoint.

image

Than place this file somewhere to DATA_DIR according to your local numeric user id. The final file name should look like "/home/oc/.local/state/keybr/user_stats/000/000/000000001" where "/home/oc/.local/state/keybr" is configured in your DATA_DIR. If you have a different user id, then update the digits accordingly.

Ottaviocr commented 8 months ago

Am Di., 5. März 2024 um 10:11 Uhr schrieb Aliaksandr Radzivanovich @.***>:

If you want to import your data, you can download the file loaded from the https://www.keybr.com/_/sync/data endpoint.

Than place this file somewhere to DATA_DIR according to your local numeric user id. The final file name should look like "/home/oc/.local/state/keybr/user_stats/000/000/000000001" where "/home/oc/.local/state/keybr" is configured in your DATA_DIR. If you have a different user id, then update the digits accordingly.

Is this documented anywhere? I am struggling to make it work. My uid and gid are 1000. I created /home/oc/.local/state/keybr/user_stats/1000/1000/ and renamed the file stats.data as /home/oc/.local/state/keybr/user_stats/1000/1000/000000001 but it didn't seem to work.

-- Ottavio Caruso

Ottaviocr commented 8 months ago

I also created .local/state/keybr/user_stats/000/000/000000001 but that doesn't work either. Let me know if I need to create a new ticket.

aradzie commented 8 months ago

I don't think it's worth documenting.

Please note we are speaking about the keybr internal ids, not the unix user ids. (1000 looks like a unix id.)

Examine the contents of the user_stats directory. If it's empty, sign in with an online account and complete a few lessons. Then a file should appear under the stats directory. It should be named as described a above, using digits from your user id. Replace that file with the one you downloaded from keybr.com. Refresh the web page to see the changes.

The directory naming scheme is as follows. If you have a user id 123456789, then the user_stats/123/456/123456789 file will be created.

It is a bad idea to keep all user files in a single giant directory, so we use use a radix tree like structure of directories.