Windows: Node execFile/execFileSync cannot run global lark-cli (.cmd shim)

Abierto
#2,826 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
55/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, node.js, powershell

Línea de trabajo

Start with the bin entry in package.json and the entry script at scripts/run.js, then check the README for any existing install or usage notes. Confirm the reported Windows behaviour by running the .cmd shim versus node scripts/run.js with execFileSync. Done means a short "Programmatic usage" section that shows the node …/scripts/run.js invocation for Windows without shell: true, pending maintainer agreement on whether an install-layout change is also wanted.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

domain/core

Summary

On Windows, after a normal npm global install of @larksuite/cli, calling:

import { execFileSync } from 'node:child_process'
execFileSync('lark-cli', ['--profile', '…', 'docs', '+fetch', /* … */], {
  encoding: 'utf8',
  stdio: ['ignore', 'pipe', 'pipe'],
})

fails, while the same command works when typed in PowerShell/cmd.

This affects programmatic / Agent callers that intentionally use execFile (no shell) to keep argv unescaped and avoid shell injection.

Environment

  • OS: Windows 10/11
  • Package: @larksuite/cli (reproduced on 1.0.97)
  • Install: npm global (lark-cli on PATH)
  • Node: 22+ / 24.x

What npm installs on Windows

Global bin typically creates:

  • lark-cli.cmd
  • lark-cli.ps1
  • real entry: node_modules/@larksuite/cli/scripts/run.js (package.json bin: { lark-cli: scripts/run.js }`)

The .cmd shim ultimately runs:

node ...\node_modules\@larksuite\cli\scripts\run.js %*

PowerShell/cmd resolve lark-cli to that shim, so interactive use works.
Node execFile / execFileSync does not run .cmd without shell: true, so looking up the bare command name lark-cli fails in Agent/tooling code.

Workaround (works today)

Spawn the Node entry directly (no shell):

execFileSync(process.execPath, [
  String.raw`C:\path\to\node_global\node_modules\@larksuite\cli\scripts\run.js`,
  '--profile', profile,
  'docs', '+fetch',
  '--doc', url,
  '--as', 'user',
  '--format', 'json',
], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })

(or resolve run.js from PATH’s */node_modules/@larksuite/cli/scripts/run.js)

Using shell: true also “works” but is undesirable for untrusted/argv-sensitive automation.

Request

  1. Document the recommended Windows programmatic invocation (node …/scripts/run.js …) for humans and AI Agents that must avoid shell: true.
  2. Optionally consider a Windows-friendly install story for non-shell spawners (e.g. document PATH layout, or ship/clarify a non-.cmd entry if feasible). Understanding this is partly an npm-on-Windows convention; even a short “Programmatic usage” note would unblock Agent integrations.

Not asking for

  • Changing Feishu OpenAPI auth or docs APIs — this is only about the CLI process entrypoint on Windows.

Thanks!

Lenguaje dominante
Go
Estrellas
18.2k
Forks
1.4k
Merge medio
1 d 3 h
PR fusionados (30 d)
18

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de larksuite/cli

Todos los issues de larksuite/cli

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.