Open grivera82 opened 1 year ago
You should use npm start from the vault-ai directory and not in the secret dir
Sorry I entered the wrong screenshot. I doesn't work from the vault-ai directory too.
root@localhost:~/vault-ai# npm start
vault-web-server@1.0.0 start bash -c 'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server' && echo && ./bin/vault-web-server
=> Environment Variables Loaded -> Installing './vault-web-server' dependencies -> Compiling './vault-web-server' ... done
2023/04/19 16:32:53 [Config] Loaded ./config/ files 2023/04/19 16:32:53 MISSING OPENAI API KEY ENV VARIABLE root@localhost:~/vault-ai#
It's okay no worries, can you please just do an "ls" in the secret directory to see if the naming is setup correctly? There should be 3 files named like this:
root@localhost ~/vault-ai/secret # ls -lahs
total 0
0 drwxr-xr-x 1 root root 4.0K Apr 18 16:03 .
0 drwxr-xr-x 1 root root 4.0K Apr 18 16:46 ..
0 -rw-r--r-- 1 root root 55 Apr 18 14:16 .gitignore
0 -rw-r--r-- 1 root root 52 Apr 18 14:16 openai_api_key
0 -rw-r--r-- 1 root root 56 Apr 18 16:03 pinecone_api_endpoint
0 -rw-r--r-- 1 root root 37 Apr 18 14:16 pinecone_api_key
The "openai_api_key" should also just include the API key and nothing else in the file but that error message indicates that the script cannot load the environment variable for the openAI API key.
root@localhost:~/vault-ai# cd secret/ root@localhost:~/vault-ai/secret# ls -lahs total 24K 4.0K drwxr-xr-x 2 root root 4.0K Apr 19 15:45 . 4.0K drwxr-xr-x 15 root root 4.0K Apr 19 16:17 .. 4.0K -rw-r--r-- 1 root root 55 Apr 19 15:38 .gitignore 4.0K -rw-r--r-- 1 root root 52 Apr 19 16:13 openai_api_key 4.0K -rw-r--r-- 1 root root 53 Apr 19 15:45 pinecone_api_endpoint 4.0K -rw-r--r-- 1 root root 37 Apr 19 15:44 pinecone_api_key root@localhost:~/vault-ai/secret#
Thanks seem that this is also ok. I just noticed that it uses "bash -c" when it runs the source command that might be the issue here as it expands before the source is run. You could try to modify the "package.json" and delete the "source" at "start:" to get it running, however this will keep the keys in the environment loaded which might be an issue.
root@localhost ~/vault-ai # cat package.json { "name": "vault-web-server", "private": true, "version": "1.0.0", "description": "vault core website", "main": "index.js", "scripts": { "start": "./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server && echo && ./bin/vault-web-server", "dev": "webpack --progress --watch", "postinstall": "source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server" },
This should work, had to use the same workaround in WSL.
Edit: Adding information about "bash -c" and sourcing envs https://unix.stackexchange.com/questions/135070/why-doesnt-source-work-when-i-call-bash-c
when I remove bash -c I get this
root@localhost:~/vault-ai# npm install
vault-web-server@1.0.0 postinstall source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server
sh: 1: source: not found npm ERR! code 127 npm ERR! path /root/vault-ai npm ERR! command failed npm ERR! command sh -c source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server
npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-04-19T16_59_15_732Z-debug-0.log root@localhost:~/vault-ai#
Yes because the "source" command is missing on your system / shell. If you remove the "source" in the package.json from the "start:" it will work.
Yes it worked and now I get a different error.
root@localhost:~/vault-ai# npm start
vault-web-server@1.0.0 start ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server' && echo && ./bin/vault-web-server
sh: 1: Syntax error: Unterminated quoted string
Because now there is a single quote in behind ./vault-web-server' <---
Can you check if it might be in the package.json? The start command should look like this one:
"start": "./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server && echo && ./bin/vault-web-server",
fixed the single quote and I get this
root@localhost:~/vault-ai# npm start
vault-web-server@1.0.0 start ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server && echo && ./bin/vault-web-server
=> Environment Variables Loaded -> Installing './vault-web-server' dependencies -> Compiling './vault-web-server' ... done
2023/04/19 17:31:48 [Config] Loaded ./config/ files 2023/04/19 17:31:48 MISSING OPENAI API KEY ENV VARIABLE root@localhost:~/vault-ai#
This is really strange, does it even load the API key into the environment?
If you just run:
echo $OPENAI_API_KEY
Does it print the API key at all or is it just empty after running "npm start"? Don't actually post the API key. If it's empty then it seem to fail loading it into the environment. If the API key is there then I might be out of ideas.
If you can also just test to run:
export OPENAI_API_KEY=ActualAPIKeyHere
Then it should set it and if you run the first command "echo $OPENAI_API_KEY" again it should show the API key. Then try to run "npm start" again.
It didn't print the API KEY.
The export command work and the server seems to be running but the website doesn't load.
root@localhost:~/vault-ai# npm start
vault-web-server@1.0.0 start ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server && echo && ./bin/vault-web-server
=> Environment Variables Loaded -> Installing './vault-web-server' dependencies -> Compiling './vault-web-server' ... done
2023/04/19 18:53:18 [Config] Loaded ./config/ files [negroni] listening on :8100 [negroni] Apr 19 18:53:27 | 200 | 1.000068ms GET / [negroni] Apr 19 18:53:42 | 200 | 970.527µs GET / [negroni] Apr 19 18:53:56 | 200 | 928.527µs GET / [negroni] Apr 19 18:54:00 | 200 | 751.913µs GET / [negroni] Apr 19 18:54:04 | 200 | 560.74µs GET /
That's good news, regarding the website you also need to run the following command in a second shell to build the template: npm run dev
I forgot to run it at first too which results in a blank page. Afterwards you can just run "npm start" no need to run "npm run dev" again if there was no update to js code.
I did run it but still no website.
root@localhost:~/vault-ai# npm run dev
vault-web-server@1.0.0 dev webpack --progress --watch
assets by chunk 169 KiB (id hint: vendors) asset vendors-node_modules_react-dropzone_dist_es_index_js-node_modules_uuid_dist_esm-browser_v4_js.bundle.js 133 KiB [compared for emit] (id hint: vendors) asset vendors-node_modules_react-router-dom_es_Link_js-node_modules_url-parse_index_js-node_modules-b6a711.bundle.js 35.9 KiB [compared for emit] (id hint: vendors) asset bundle.js 1.18 MiB [compared for emit] (name: app) asset components_Pages_LandingPage_index_jsx.bundle.js 105 KiB [compared for emit] asset components_Header_index_jsx.bundle.js 24 KiB [compared for emit] orphan modules 42 KiB [orphan] 27 modules runtime modules 6.98 KiB 10 modules modules by path ./node_modules/ 1.19 MiB 68 modules modules by path ./components/ 93.9 KiB modules by path ./components/.less 22.8 KiB 6 modules modules by path ./components/Util/.jsx 7.81 KiB 4 modules modules by path ./components/Pages/LandingPage/ 20.7 KiB 3 modules modules by path ./components/Header/ 8.88 KiB 3 modules modules by path ./components/Page/ 6.87 KiB 3 modules modules by path ./components/Footer/ 19.2 KiB 3 modules modules by path ./components/*.jsx 5.14 KiB ./components/index.jsx 430 bytes [built] [code generated] ./components/routes.jsx 4.72 KiB [built] [code generated] ./components/Go/index.jsx 2.48 KiB [built] [code generated] webpack 5.64.0 compiled successfully in 5815 ms
Hello @Ninn0x4F I was seeing the same issues earlier on a standard, up-to-date Mac environment. (zsh, not bash)
I tried a lot of things, including hard-coding the API keys into the script. Eventually I did get the website to load, but only once, then it went back to having this error. No idea what would have caused that.
But yeah, I'd recommend a more standard approach to using these keys. Can you just use a env variables in a single file? Looking forward to getting this working, thanks for the code!
edit sorry i meant running the command: source ./scripts/source-me.sh before npm start and npm run dev, after making the below changes:
*ubuntu vm with bash added to package.json file "scripts": { "start": "bash -c 'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server' && echo && ./bin/vault-web-server", "dev": "webpack --progress --watch", "postinstall": "bash -c 'source ./scripts/source-me.sh && ./scripts/go-compile.sh ./vault-web-server'" },
i think it could be because thats getting ran in a different terminal that doesnt like source, but i could be wayyy off... if anyone has more info on this i would love to hear it!
bash -c
I am having the same problem, I am working on a macbook, did you solved that problem, bro?
Getting the following error. Running it on Ubuntu.
root@localhost:~/vault-ai/secret# npm start
=> Environment Variables Loaded -> Installing './vault-web-server' dependencies -> Compiling './vault-web-server' ... done
2023/04/19 16:24:50 [Config] Loaded ./config/ files 2023/04/19 16:24:50 MISSING OPENAI API KEY ENV VARIABLE root@localhost:~/vault-ai/secret#