Skip to content

clerk env pull --file <path> prints success but writes no file (exits 1) when framework cannot be detected #269

Description

@gtrusler

Summary

clerk env pull --app <id> --instance dev --file <absolute path> prints Environment variables written to <path> and exits with code 1, but no file is created at the path. Reproducible in both directories without a package.json and in directories with a package.json that has no recognized framework dependency.

Environment

  • clerk CLI: 1.1.1
  • Install: Homebrew (/opt/homebrew/bin/clerk)
  • OS: macOS, Darwin 25.4.0 arm64

Reproduction

# From any directory (here: a non-framework dir)
$ clerk env pull --app app_xxx --instance dev --verbose --file ~/clerk-dev.env
config: reading /Users/u/Library/Preferences/clerk-cli/config.json
env: profiles from compile-time CLI_ENV_PROFILES (production, staging)
env: active environment is "production" (platformApiUrl=https://api.clerk.com)
framework: no package.json at /Users/u/Developer/some-dir or unable to parse
credentials: checking keyring (service=clerk-cli, account=oauth-access-token)
credentials: found session in keyring
plapi: using OAuth token from credential store for auth (env=production, target=https://api.clerk.com)
plapi: GET https://api.clerk.com/v1/platform/applications/app_xxx?include_secret_keys=true
...
framework: no package.json at /Users/u/Developer/some-dir or unable to parse
Environment variables written to /Users/u/clerk-dev.env
$ echo $?
1
$ ls -la ~/clerk-dev.env
ls: /Users/u/clerk-dev.env: No such file or directory

Also reproduces from inside a directory with a package.json that lacks a Clerk-recognized framework — the verbose log changes to framework: no match in <path>/package.json dependencies but the same exit-1-with-no-file behavior occurs.

Expected

Either:

  1. The file is written to --file <path> regardless of framework detection (since --file is an explicit absolute path the user provided), or
  2. The CLI exits non-zero with an explanatory error, not the misleading "Environment variables written to " success message.

Actual

CLI prints the success message and exits 1 with no file on disk. Misleading for users and breaks scripted workflows.

Workaround

Use the Platform API directly:

clerk api "/platform/applications/<app_id>?include_secret_keys=true" --platform \
  | jq -r '.instances[] | select(.environment_type=="development") | .secret_key'

Suspected cause

The "framework detection failed" path appears to short-circuit the actual write step while still printing the post-write success message. --file <path> should bypass framework-specific logic since the user has explicitly named the target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions