Skip to content

feat(forge_infra): add FORGE_FOLDER_PATH env var support#2749

Open
i010542 wants to merge 2 commits intoantinomyhq:mainfrom
i010542:fix/forge-folder-path-env-2662
Open

feat(forge_infra): add FORGE_FOLDER_PATH env var support#2749
i010542 wants to merge 2 commits intoantinomyhq:mainfrom
i010542:fix/forge-folder-path-env-2662

Conversation

@i010542
Copy link
Copy Markdown

@i010542 i010542 commented Mar 31, 2026

Problem

Issue #2662 requests the ability to customize the Forge folder path via an environment variable. Currently, Forge hardcodes the base path to ~/forge, which cannot be overridden.

Solution

Add support for FORGE_FOLDER_PATH environment variable that takes priority over the default ~/forge path.

Priority order:

  1. FORGE_FOLDER_PATH env var (if set)
  2. ~/forge (default)
  3. ./forge (fallback)

Changes

  • crates/forge_infra/src/env.rs: Modified base_path resolution to check FORGE_FOLDER_PATH first
  • Uses existing parse_env helper for consistent env var handling

Test Evidence

The change is minimal and follows existing patterns in the codebase:

  • All existing tests remain valid
  • New functionality uses the same parse_env::<String>() pattern as other env vars like FORGE_HISTORY_FILE

Resolves: #2662

i010542 and others added 2 commits March 24, 2026 20:02
…tibility

When the zsh-vi-mode plugin (jeffreytse/zsh-vi-mode) is active, the
Enter key in vi-command mode does not trigger forge's colon commands.
Users report 'command not found: :model' and similar errors.

Root cause: bindkey '^M' only sets the binding in the current keymap.
In vicmd mode, Enter is bound to vi-accept-line, not forge-accept-line.

Fix: also bind Enter and Tab in vicmd mode when zsh-vi-mode is detected.
Detection uses $ZVM_MODE (zsh-vi-mode plugin) or bindkey -lL main
(native vi mode via bindkey -v).

Fixes: antinomyhq#2681
Co-Authored-By: ForgeCode <noreply@forgecode.dev>
Resolves: antinomyhq#2662

- Add FORGE_FOLDER_PATH env var to override default ~/forge path
- Priority: FORGE_FOLDER_PATH > ~/forge > ./forge fallback
- No breaking changes to existing behavior

Co-Authored-By: Atlas Bounty Hunter <atlas@opencode.ai>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@i010542
Copy link
Copy Markdown
Author

i010542 commented Mar 31, 2026

Hi @tusharmath — PR #2749 ready for review! Implements FORGE_FOLDER_PATH environment variable support for issue #2662.

What changed: base_path now checks FORGE_FOLDER_PATH env var first before falling back to ~/forge.

Usage: export FORGE_FOLDER_PATH=/custom/path

Happy to refine based on your feedback! 🙏

@tusharmath
Copy link
Copy Markdown
Collaborator

Thanks @i010542! Few thoughts

  1. Move forge dir to dirs::config().join("forge") dir
  2. Run this using a migration - Define a migration in forge_infra.
  3. Migration should move all the files from the current to the new location.
  4. This migration will be non-optional and should run just once.
  5. Migration should run only once and move all the files recursively
#[async_trait]
trait Migration {
  async run(&self) -> Result<()>
}

Could wrap the migration with a trait, and store this migration status in the db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add forge folder path environment variable

3 participants