Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop app fails to start with error - Error: failed to setup credential helpers: failed to get latest release for after clearing config/cache for gptscript and desktop app. #475

Closed
sangee2004 opened this issue Sep 10, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@sangee2004
Copy link

Electron build- 2be2f666

Steps to led to the problem:
I had a working version of Desktop app in this version.
I usually start the production version of the app using ./electron-dist/mac-arm64/Acorn.app/Contents/MacOS/Acorn
I quit the app.
Delete all gptscript credenial entries except github.com/gptscript-ai/gateway
Cleared the config/cache for gptscript and desktop app.

rm -rf ~/Library/Application\ Support/acorn
rm -rf ~/Library/Application\ Support/gptscript
rm -rf ~/Library/Caches/gptscript

After this I was not able to get the app to start successfully. I kept seeing this error:

./electron-dist/mac-arm64/Acorn.app/Contents/MacOS/Acorn
2024-09-09T16:26:08.407Z [server] [INFO] GPTSCRIPT_BIN=/Users/sangeethahariharan/acorn/desktop/electron-dist/mac-arm64/Acorn.app/Contents/Resources/app.asar.unpacked/node_modules/@gptscript-ai/gptscript/bin/gptscript
2024-09-09T16:26:09.009Z [server] [INFO] GPTScript config initialized
2024-09-09T16:26:09.094Z [server] [INFO] Config file updated successfully
2024-09-09T16:26:09.113Z [server] [INFO] > Server is ready at http://localhost:30000/
2024-09-09T16:26:09.113Z [server] [INFO] > Electron app started at http://localhost:30000/
2024-09-09T16:26:10.008Z [server] [ERROR] Error: failed to setup credential helpers: failed to get latest release for 
    at IncomingMessage.<anonymous> (/Users/sangeethahariharan/acorn/desktop/electron-dist/mac-arm64/Acorn.app/Contents/Resources/app.asar/.next/server/chunks/666.js:28:104797)
    at IncomingMessage.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  digest: '462093123'
}
2024-09-09T16:26:10.015Z [client] [ERROR] Uncaught (in promise) Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
^C%
Screenshot 2024-09-09 at 9 10 43 AM

I was in this state even after I quit the app and relaunched it multiple times.

I tried running gptsctipt in cli after which the next attempt to launch the desktop app succeeded. I am not sure how running gptsctipt would have help correct the situation I was in.

2024-09-09T16:26:08.407Z [server] [INFO] GPTSCRIPT_BIN=/Users/sangeethahariharan/acorn/desktop/electron-dist/mac-arm64/Acorn.app/Contents/Resources/app.asar.unpacked/node_modules/@gptscript-ai/gptscript/bin/gptscript
2024-09-09T16:26:09.009Z [server] [INFO] GPTScript config initialized
2024-09-09T16:26:09.094Z [server] [INFO] Config file updated successfully
2024-09-09T16:26:09.113Z [server] [INFO] > Server is ready at http://localhost:30000/
2024-09-09T16:26:09.113Z [server] [INFO] > Electron app started at http://localhost:30000/
2024-09-09T16:26:10.008Z [server] [ERROR] Error: failed to setup credential helpers: failed to get latest release for 
    at IncomingMessage.<anonymous> (/Users/sangeethahariharan/acorn/desktop/electron-dist/mac-arm64/Acorn.app/Contents/Resources/app.asar/.next/server/chunks/666.js:28:104797)
    at IncomingMessage.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  digest: '462093123'
}
2024-09-09T16:26:10.015Z [client] [ERROR] Uncaught (in promise) Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
^C% which gptscript
/usr/local/bin/gptscript

 % gptscript
Usage:
  gptscript [flags] PROGRAM_FILE [INPUT...]
  gptscript [command]

Available Commands:
  credential    List stored credentials
  eval          
  fmt           
  getenv        Looks up an environment variable for use in GPTScript tools
  parse         

Flags:
      --cache-dir string                    Directory to store cache (default: $XDG_CACHE_HOME/gptscript) ($GPTSCRIPT_CACHE_DIR)
      --chat-state string                   The chat state to continue, or null to start a new chat and return the state ($GPTSCRIPT_CHAT_STATE)
  -C, --chdir string                        Change current working directory ($GPTSCRIPT_CHDIR)
      --color                               Use color in output (default true) ($GPTSCRIPT_COLOR)
      --config string                       Path to GPTScript config file ($GPTSCRIPT_CONFIG)
      --confirm                             Prompt before running potentially dangerous commands ($GPTSCRIPT_CONFIRM)
      --credential-context string           Context name in which to store credentials ($GPTSCRIPT_CREDENTIAL_CONTEXT) (default "default")
      --credential-override strings         Credentials to override (ex: --credential-override github.com/example/cred-tool:API_TOKEN=1234) ($GPTSCRIPT_CREDENTIAL_OVERRIDE)
      --debug                               Enable debug logging ($GPTSCRIPT_DEBUG)
      --debug-messages                      Enable logging of chat completion calls ($GPTSCRIPT_DEBUG_MESSAGES)
      --default-model string                Default LLM model to use ($GPTSCRIPT_DEFAULT_MODEL) (default "gpt-4o")
      --default-model-provider string       Default LLM model provider to use, this will override OpenAI settings ($GPTSCRIPT_DEFAULT_MODEL_PROVIDER)
      --disable-cache                       Disable caching of LLM API responses ($GPTSCRIPT_DISABLE_CACHE)
      --disable-tui                         Don't use chat TUI but instead verbose output ($GPTSCRIPT_DISABLE_TUI)
      --dump-state string                   Dump the internal execution state to a file ($GPTSCRIPT_DUMP_STATE)
      --events-stream-to string             Stream events to this location, could be a file descriptor/handle (e.g. fd://2), filename, or named pipe (e.g. \\.\pipe\my-pipe) ($GPTSCRIPT_EVENTS_STREAM_TO)
      --force-chat                          Force an interactive chat session if even the top level tool is not a chat tool ($GPTSCRIPT_FORCE_CHAT)
      --force-sequential                    Force parallel calls to run sequentially ($GPTSCRIPT_FORCE_SEQUENTIAL)
      --github-enterprise-hostname string   The host name for a Github Enterprise instance to enable for remote loading ($GPTSCRIPT_GITHUB_ENTERPRISE_HOSTNAME)
  -h, --help                                help for gptscript
  -f, --input string                        Read input from a file ("-" for stdin) ($GPTSCRIPT_INPUT_FILE)
      --list-models                         List the models available and exit ($GPTSCRIPT_LIST_MODELS)
      --list-tools                          List built-in tools and exit ($GPTSCRIPT_LIST_TOOLS)
      --no-trunc                            Do not truncate long log messages ($GPTSCRIPT_NO_TRUNC)
      --openai-api-key string               OpenAI API KEY ($OPENAI_API_KEY)
      --openai-base-url string              OpenAI base URL ($OPENAI_BASE_URL)
      --openai-org-id string                OpenAI organization ID ($OPENAI_ORG_ID)
  -o, --output string                       Save output to a file, or - for stdout ($GPTSCRIPT_OUTPUT)
  -q, --quiet                               No output logging (set --quiet=false to force on even when there is no TTY) ($GPTSCRIPT_QUIET)
      --save-chat-state-file string         A file to save the chat state to so that a conversation can be resumed with --chat-state ($GPTSCRIPT_SAVE_CHAT_STATE_FILE)
      --sub-tool string                     Use tool of this name, not the first tool in file ($GPTSCRIPT_SUB_TOOL)
      --ui                                  Launch the UI ($GPTSCRIPT_UI)
  -v, --version                             version for gptscript
      --workspace string                    Directory to use for the workspace, if specified it will not be deleted on exit ($GPTSCRIPT_WORKSPACE)

Use "gptscript [command] --help" for more information about a command.
 % gptscript credentials
CREDENTIAL                        EXPIRES IN
github.com/gptscript-ai/gateway   19h58m15s

% ./electron-dist/mac-arm64/Acorn.app/Contents/MacOS/Acorn
2024-09-09T16:29:51.043Z [server] [INFO] GPTSCRIPT_BIN=/Users/sangeethahariharan/acorn/desktop/electron-dist/mac-arm64/Acorn.app/Contents/Resources/app.asar.unpacked/node_modules/@gptscript-ai/gptscript/bin/gptscript
2024-09-09T16:29:51.645Z [server] [INFO] GPTScript config initialized
2024-09-09T16:29:51.725Z [server] [INFO] Config file updated successfully
2024-09-09T16:29:51.745Z [server] [INFO] > Server is ready at http://localhost:30000/
2024-09-09T16:29:51.745Z [server] [INFO] > Electron app started at http://localhost:30000/
@sangee2004 sangee2004 added the bug Something isn't working label Sep 10, 2024
@thedadams
Copy link
Contributor

This issue wasn't reproducible when it happened. The intention of creating this issue was that we need to bubble up the error when then downloading of the credential helpers fails for some reason. Here, you get a generic error that doesn't explain anything. The user should see some indication of why the download failed.

This PR attempts to do that: gptscript-ai/gptscript#845

@thedadams thedadams self-assigned this Sep 10, 2024
@thedadams
Copy link
Contributor

The fix to bubble up the error has been merged to gptscript. Here are some steps to test these changes.

  1. Build main of gptscript.
  2. In the desktop directory, set GPTSCRIPT_BIN to the binary built above.
  3. Also in the desktop directory, set GPTSCRIPT_CRED_HELPERS_ROOT to a GitHub repo that doesn't exist. I was using https://github.com/gptscript-ai/gptscript-credential-help.git
  4. Clear all caches
  5. Run npm run dev:electron

You should see more information about why getting the credential helpers failed.

@sangee2004
Copy link
Author

Was able to reproduce the issue by following steps from #475 (comment) using the release version of gptscript (without setting GPTSCRIPT_BIN env variable).

When testing with gptscript version -v0.0.0-dev+c0f116cf (by setting GPTSCRIPT_BIN env variable) , error messages presented show more details like 404/403.

Image
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants