W
Wasp-langβ€’16mo ago
bme_vegas

WASP CLI PROCESS ERROR Error: spawn wasp-cli ENOENT

Trying to run wasp-ai locally. When I generate a new app using any of the templates, I get the error above. Not sure where else to look for what's breaking. Any pointers are appreciated.
12 Replies
bme_vegas
bme_vegasOPβ€’16mo ago
[Server!] WASP CLI PROCESS ERROR Error: spawn wasp-cli ENOENT [Server!] at ChildProcess._handle.onexit (node:internal/child_process:283:19) [Server!] at onErrorNT (node:internal/child_process:476:16) [Server!] at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { [Server!] errno: -2, [Server!] code: 'ENOENT', [Server!] syscall: 'spawn wasp-cli',
bme_vegas
bme_vegasOPβ€’16mo ago
No description
matijash
matijashβ€’16mo ago
Aha @martinsos will provide specific info πŸ™‚
martinsos
martinsosβ€’16mo ago
Hey @bme_vegas , happy to help! So from what I see, you are trying to run the actual GPT Web App Generator locally -> we haven't made it yet super friendly to run locally, so that is why it is a bit confusing on how to run it. One easy way to run Wasp AI locally is to run it via CLI, not via app, as per instructions in the very last entry of the GPT Web App Generator's FAQ (on its webpage) -> so that is certainly the easiest, and it will generate the app directly on your disk. But, you won't have a nice UI that app brings. As for running the app, which is what you tried, there are a couple of things it requires: 1. Local installation of wasp that is AI capable. It looks for wasp-cli actually, because that is how we alias our wasp CLI during development. You can get that installed by going into waspc dir in the repo and following instructions for installation (running cabal install) but that will require that you have Haskell installed and will take a long time. Another option is that you install AI capable version of wasp as per instructions provided in the FAQ that I mentioned above, and once you have that, hunt down the line in Web App Generator app that references wasp-cli and change that to wasp, so it will use that wasp binary. 2. You will also possibly need to set some ENV vars in .env.server, for example JWT_SECRET. But maybe you won't hit those, I am not sure.
bme_vegas
bme_vegasOPβ€’16mo ago
I have a penchant for rolling wheels up steep hills, so... Thanks for the pointers, I haven't worked much with wasp. I'm interested in seeing wasp-ai run locally and updating it to talk to Azure's OpenAI service to see how it compares. Where can I find this?
Another option is that you install AI capable version of wasp as per instructions provided in the FAQ
@martinsos curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.11.1-wasp-ai-11 I assume gets me a wasp that supports "new-ai" but doesn't seem to πŸ˜•
MEE6
MEE6β€’16mo ago
Wohooo @bme_vegas, you just became a Waspeteer level 1!
Filip
Filipβ€’16mo ago
I assume gets me a wasp that supports "new-ai" but doesn't seem to πŸ˜•
hey @bme_vegas, let's get to the bottom of this! What happens when you try to run it?
wasp new-ai:disk MyAwesomeApp "Description of my awesome app." "{ \"defaultGptModel\": \"gpt-4\" }"
wasp new-ai:disk MyAwesomeApp "Description of my awesome app." "{ \"defaultGptModel\": \"gpt-4\" }"
martinsos
martinsosβ€’16mo ago
Yes it should! But maybe it is not obvious that it does -> @Filip asked a good question to test if it does support AI capabilities, and if that works, then you need to adjust the wasp-ai app itself to use this binary as I described above.
bme_vegas
bme_vegasOPβ€’15mo ago
Apologies for the delay, looks like I just need to grab an API key ❌ --- [Error] Missing OPENAI_API_KEY environment variable: ----------------------- Wasp AI uses ChatGPT to generate your project, and therefore requires you to provide it with an OpenAI API key. You can obtain this key via your OpenAI account's user settings (https://platform.openai.com/account/api-keys). Then, add export OPENAI_API_KEY=<yourkeyhere> to .bash_profile or .profile, restart your shell, and you should be good to go.
Filip
Filipβ€’15mo ago
That's right! You only need your key for running Wasp AI locally though. The web app uses our key πŸ™‚
bme_vegas
bme_vegasOPβ€’15mo ago
I upgraded my subscription and will try it again in just a bit, I'm expecting it to work. I had tried newai using the parameters from the errored output to no avail. woot! ====== RESPONSE ====== ChatResponse { id = "chatcmpl-7tMd0jFf18jwUPx58YEkHZjOS9jLp" , object = "chat.completion" , created = 1693429378 , model = "gpt-4-0613" Looks like it's off to the races. So to use this wasp version with the web app - should I just do this: else { waspCliProcess = spawn("wasp", waspCliProcessArgs, { env: { ...process.env, waspc_datadir: undefined }, }); or is this good enough to? if (process.env.NODE_ENV !== "production") { waspCliProcess = spawn("wasp", waspCliProcessArgs); }
martinsos
martinsosβ€’15mo ago
I think the best option will be going with the latter. For the cleanest result, replace
if (process.env.NODE_ENV === "production") {
waspCliProcess = spawn("wasp", waspCliProcessArgs);
} else {
// NOTE: In dev when we use `wasp-cli`, we want to make sure that if this app is run via `wasp` that its datadir env var does not propagate,
// so we reset it here. This is problem only if you run app with `wasp` and let it call `wasp-cli` here.
waspCliProcess = spawn("wasp-cli", waspCliProcessArgs, {
env: { ...process.env, waspc_datadir: undefined },
});
}
if (process.env.NODE_ENV === "production") {
waspCliProcess = spawn("wasp", waspCliProcessArgs);
} else {
// NOTE: In dev when we use `wasp-cli`, we want to make sure that if this app is run via `wasp` that its datadir env var does not propagate,
// so we reset it here. This is problem only if you run app with `wasp` and let it call `wasp-cli` here.
waspCliProcess = spawn("wasp-cli", waspCliProcessArgs, {
env: { ...process.env, waspc_datadir: undefined },
});
}
with
// NOTE(bme_vegas): I edited this piece of code to directly call my `wasp` installation, assuming it is the version of `wasp` that supports AI.
waspCliProcess = spawn("wasp", waspCliProcessArgs);
// NOTE(bme_vegas): I edited this piece of code to directly call my `wasp` installation, assuming it is the version of `wasp` that supports AI.
waspCliProcess = spawn("wasp", waspCliProcessArgs);
I haven't tried this, but I think it should be ok! An nice job on managing to run wasp directly, that output is looking good indeed, those are calls to GPT! CLI has all the functionalities that web app has btw -> web app is just UI for it. Ok, except for storing the generated project in the database and sharing it around. But regarding generating the code, that is CLI that is doing the work.
Want results from more Discord servers?
Add your server