BuilderIO / ai-shell

A CLI that converts natural language to shell commands.
MIT License
3.92k stars 238 forks source link

Crash on versions 0.1.14 and up #64

Closed Irian-Adappty closed 1 year ago

Irian-Adappty commented 1 year ago

I'm on Linux Mint distribution and the package works great on version 0.1.13 but any higher version crashes on any command. Output of any command I try starting with 'ai':

cat: /etc/upstream-release: Is a directory
node:internal/errors:867
  const err = new Error(message);
              ^

Error: Command failed: cat /etc/*release
cat: /etc/upstream-release: Is a directory

    at checkExecSyncError (node:child_process:885:11)
    at execSync (node:child_process:957:15)
    at osReleaseSync (/home/irian-adappty/.nvm/versions/node/v19.9.0/lib/node_modules/@builder.io/ai-shell/node_modules/@nexssp/os/lib/distro.js:21:12)
    at module.exports.get (/home/irian-adappty/.nvm/versions/node/v19.9.0/lib/node_modules/@builder.io/ai-shell/node_modules/@nexssp/os/lib/distro.js:47:25)
    at Object.name (/home/irian-adappty/.nvm/versions/node/v19.9.0/lib/node_modules/@builder.io/ai-shell/node_modules/@nexssp/os/legacy.js:4:20)
    at getOperationSystemDetails (file:///home/irian-adappty/.nvm/versions/node/v19.9.0/lib/node_modules/@builder.io/ai-shell/dist/cli.mjs:488:13)
    at file:///home/irian-adappty/.nvm/versions/node/v19.9.0/lib/node_modules/@builder.io/ai-shell/dist/cli.mjs:493:37
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25) {
  status: 1,
  signal: null,
  output: [
    null,
    Buffer(475) [Uint8Array] [
       68,  73,  83,  84,  82,  73,  66,  95,  73,  68, 61,  76,
      105, 110, 117, 120,  77, 105, 110, 116,  10,  68, 73,  83,
       84,  82,  73,  66,  95,  82,  69,  76,  69,  65, 83,  69,
       61,  50,  48,  46,  51,  10,  68,  73,  83,  84, 82,  73,
       66,  95,  67,  79,  68,  69,  78,  65,  77,  69, 61, 117,
      110,  97,  10,  68,  73,  83,  84,  82,  73,  66, 95,  68,
       69,  83,  67,  82,  73,  80,  84,  73,  79,  78, 61,  34,
       76, 105, 110, 117, 120,  32,  77, 105, 110, 116, 32,  50,
       48,  46,  51,  32,
      ... 375 more items
    ],
    Buffer(43) [Uint8Array] [
       99,  97, 116,  58,  32,  47, 101, 116,  99,
       47, 117, 112, 115, 116, 114, 101,  97, 109,
       45, 114, 101, 108, 101,  97, 115, 101,  58,
       32,  73, 115,  32,  97,  32, 100, 105, 114,
      101,  99, 116, 111, 114, 121,  10
    ]
  ],
  pid: 55561,
  stdout: Buffer(475) [Uint8Array] [
     68,  73,  83,  84,  82,  73,  66,  95,  73,  68, 61,  76,
    105, 110, 117, 120,  77, 105, 110, 116,  10,  68, 73,  83,
     84,  82,  73,  66,  95,  82,  69,  76,  69,  65, 83,  69,
     61,  50,  48,  46,  51,  10,  68,  73,  83,  84, 82,  73,
     66,  95,  67,  79,  68,  69,  78,  65,  77,  69, 61, 117,
    110,  97,  10,  68,  73,  83,  84,  82,  73,  66, 95,  68,
     69,  83,  67,  82,  73,  80,  84,  73,  79,  78, 61,  34,
     76, 105, 110, 117, 120,  32,  77, 105, 110, 116, 32,  50,
     48,  46,  51,  32,
    ... 375 more items
  ],
  stderr: Buffer(43) [Uint8Array] [
     99,  97, 116,  58,  32,  47, 101, 116,  99,
     47, 117, 112, 115, 116, 114, 101,  97, 109,
     45, 114, 101, 108, 101,  97, 115, 101,  58,
     32,  73, 115,  32,  97,  32, 100, 105, 114,
    101,  99, 116, 111, 114, 121,  10
  ]
}

Things I've tried:

My OS details:

Distributor ID: Linuxmint
Description:    Linux Mint 20.3
Release:    20.3
Codename:   una

Linux linux 5.4.0-147-generic #164-Ubuntu SMP Tue Mar 21 14:23:17 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Video of the issue: https://contecnika-my.sharepoint.com/:v:/g/personal/irian_caigo_es/EU1juhHdlB1BugdA3iTy0hAB5TRO_mNWaf9pgVwP8ONa2Q?e=IDzBxM

steve8708 commented 1 year ago

@qihangnet this seems to have come from your update https://github.com/BuilderIO/ai-shell/pull/62 would you be able to take a look at this?

qihangnet commented 1 year ago

@steve8708 He said that this issue has been present since version 0.13, and it should not be caused by my PR. the error message is cat: /etc/upstream-release: Is a directory. Is this an error command generated by AI-Shell after executing the prompt? @Irian-Adappty Can you show me your prompt?

Irian-Adappty commented 1 year ago

Sure @qihangnet here's a video of the process and how it gives error: https://contecnika-my.sharepoint.com/:v:/g/personal/irian_caigo_es/EU1juhHdlB1BugdA3iTy0hAB5TRO_mNWaf9pgVwP8ONa2Q?e=IDzBxM

qihangnet commented 1 year ago

@Irian-Adappty I have found the cause: referencing package @nexssp/os in PR #49 . The method for determining the Linux system distribution in this line of code has an issue. This line of code should be:

return execSync('cat /etc/os-release').toString().trim()
qihangnet commented 1 year ago

I have submitted a PR for @nexssp/os: https://github.com/nexssp/os/pull/6. After it is merged and released, I will update the package version of ai-shell to fix this bug.

qihangnet commented 1 year ago

Additionally, a friendly reminder: @Irian-Adappty please be mindful of protecting your OpenAI API KEY in the video and do not expose it in public to avoid being misused. πŸ˜„

Irian-Adappty commented 1 year ago

Oh great spotting @qihangnet !

Command cat /etc/*-release outputs 1 file and 1 directory: /etc/os-release and /etc/upstream-release which is a directory and crashes. So it should be as you say: cat /etc/os-release.

As per the API key don't worry, I've revoked it before posting the video (it's shown in the last second of it actually)

qihangnet commented 1 year ago

@Irian-Adappty @steve8708 PR https://github.com/BuilderIO/ai-shell/pull/72 will fix it.

steve8708 commented 1 year ago

Released in v0.1.21!

qihangnet commented 1 year ago

That's the speed of a πŸš€ ! πŸ˜„

Irian-Adappty commented 1 year ago

It works! Many thanks! This has been fixed very quickly and I can now use the latest version πŸ˜‹

image

Irian-Adappty commented 1 year ago

Hey @qihangnet @steve8708

73

qihangnet commented 1 year ago

@Irian-Adappty I'll save this great screenshot to my album, πŸ˜„