larksuite / larksuite/cli

lark-cli enters Hermes context when HERMES_HOME is inherited, then bind ignores HERMES_HOME path

Open
#1,405 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

domain/auth domain/core
Dominant language
Go
Stars
17.3k
Forks
1.4k
Avg merge
2d 4h
Merged PRs (30d)
105

Description

Summary

After installing Hermes, unrelated CLI/automation processes that happen to inherit HERMES_HOME start failing when running lark-cli.

lark-cli detects a Hermes context and refuses to use the existing local lark-cli config, returning:

{
  "ok": false,
  "error": {
    "type": "config",
    "subtype": "not_configured",
    "message": "hermes context detected but lark-cli is not bound to it",
    "hint": "read `lark-cli config bind --help`, then ask the user to confirm intent and identity preset..."
  }
}

However, when trying to bind Hermes explicitly, lark-cli does not appear to use the HERMES_HOME path that triggered Hermes detection. Instead, it looks for a different default path:

{
  "ok": false,
  "error": {
    "type": "config",
    "subtype": "invalid_config",
    "message": "failed to read Hermes config: open C:\\Users\\example\\.hermes\\.env: The system cannot find the path specified.",
    "hint": "verify Hermes is installed and configured at C:\\Users\\example\\.hermes\\.env"
  }
}

In this environment, HERMES_HOME points somewhere else, for example:

HERMES_HOME=C:\Users\example\AppData\Local\hermes

Expected behavior

If lark-cli detects Hermes because HERMES_HOME is present, then one of the following should happen:

  1. config bind --source hermes should read Hermes config from HERMES_HOME, or
  2. lark-cli should not enter Hermes context unless Hermes config can actually be resolved, or
  3. there should be a documented way to force normal local config mode, e.g. an env var or flag like --ignore-agent-context.

Actual behavior

Any unrelated process that inherits HERMES_HOME is treated as Hermes context.

This breaks existing lark-cli usage in non-Hermes automation tasks. Commands such as:

lark-cli auth status
lark-cli config show
lark-cli im +chat-messages-list --as user ...

fail before using the existing local config.

If HERMES_HOME is removed from the current shell, the same commands work again and use the normal local config:

Remove-Item Env:HERMES_HOME -ErrorAction SilentlyContinue
lark-cli auth status

Reproduction

  1. Have a working local lark-cli config.
  2. Install Hermes or otherwise set HERMES_HOME to a Hermes data directory.
  3. In a non-Hermes shell or automation process that inherits HERMES_HOME, run:
lark-cli auth status
  1. Observe hermes context detected but lark-cli is not bound to it.
  2. Try:
lark-cli config bind --source hermes --identity user-default
  1. Observe that bind looks for C:\Users\example\.hermes\.env instead of the path from HERMES_HOME.

Impact

This causes unrelated automation jobs that use lark-cli to fail after Hermes is installed, even though those jobs are not Hermes jobs and already have a valid local lark-cli config.

Version

lark-cli version 1.0.51

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with HERMES_HOME set, then trace the lark-cli Hermes context detection and the config bind --source hermes entry points. Compare the path used for detection with the path used when reading Hermes config. Done means unrelated commands retain local-config behavior or explicit Hermes binding uses HERMES_HOME, with the chosen behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.