go install codeberg.org/goern/forgejo-mcp/v2@latest fails due to replace directive in go.mod #67

Closed
opened 2026-02-06 18:48:44 +01:00 by goern · 4 comments
Owner

Problem

Running go install codeberg.org/goern/forgejo-mcp/v2@latest fails with:

go: codeberg.org/goern/forgejo-mcp/v2@latest (in codeberg.org/goern/forgejo-mcp/[email protected]):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

Cause

The go.mod contains a replace directive:

replace codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2 => codeberg.org/redbeard/forgejo-sdk/forgejo/v2 v2.2.0

Go refuses to go install pkg@version when the module's go.mod has replace directives, because the build would behave differently than if the module were used as a dependency.

Workaround

Clone and build locally:

git clone https://codeberg.org/goern/forgejo-mcp.git
cd forgejo-mcp
go install .

Resolution options

  1. Get changes merged upstream into mvdkleijn/forgejo-sdk so the replace is no longer needed
  2. Fork the SDK under a different import path (e.g. codeberg.org/goern/forgejo-sdk), update imports, and drop the replace
## Problem Running `go install codeberg.org/goern/forgejo-mcp/v2@latest` fails with: ``` go: codeberg.org/goern/forgejo-mcp/v2@latest (in codeberg.org/goern/forgejo-mcp/[email protected]): The go.mod file for the module providing named packages contains one or more replace directives. It must not contain directives that would cause it to be interpreted differently than if it were the main module. ``` ## Cause The `go.mod` contains a `replace` directive: ``` replace codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2 => codeberg.org/redbeard/forgejo-sdk/forgejo/v2 v2.2.0 ``` Go refuses to `go install pkg@version` when the module's `go.mod` has `replace` directives, because the build would behave differently than if the module were used as a dependency. ## Workaround Clone and build locally: ```bash git clone https://codeberg.org/goern/forgejo-mcp.git cd forgejo-mcp go install . ``` ## Resolution options 1. **Get changes merged upstream** into `mvdkleijn/forgejo-sdk` so the `replace` is no longer needed 2. **Fork the SDK** under a different import path (e.g. `codeberg.org/goern/forgejo-sdk`), update imports, and drop the `replace`
Author
Owner

Analysis

The replace directive currently in go.mod:

replace codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2 => codeberg.org/redbeard/forgejo-sdk/forgejo/v2 v2.2.0

…is actually a no-op. The redbeard/forgejo-sdk fork at the v2.2.0 tag has an identical main branch to upstream mvdkleijn/forgejo-sdk (same commit 5f3afea2fa). The replace was likely added in anticipation of adopting Brian's expanded Actions API from the feature/expanded-actions branch, but that branch is untagged and unreleased.

Why we can't just switch import paths

The fork's go.mod on feature/expanded-actions still declares:

module codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2

Go enforces that the declared module path must match the import path. This means:

  • To use Brian's code → we need a replace directive
  • For go install @latest to work → we need no replace directive

These are mutually exclusive under Go's module system.

Resolution

Immediate fix (this issue): Remove the no-op replace directive. This unblocks go install codeberg.org/goern/forgejo-mcp/v2@latest with zero functional change, since the replace was pointing at identical code.

Follow-up: Adopting Brian's expanded Actions API (which adds comprehensive Actions support for user/org/repo scopes) is blocked until his changes are merged upstream into mvdkleijn/forgejo-sdk and released. Brian offered to PR on issue #84 and the maintainer was receptive — just needs the PR to be filed.

## Analysis The `replace` directive currently in `go.mod`: ``` replace codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2 => codeberg.org/redbeard/forgejo-sdk/forgejo/v2 v2.2.0 ``` …is actually a **no-op**. The `redbeard/forgejo-sdk` fork at the `v2.2.0` tag has an identical `main` branch to upstream `mvdkleijn/forgejo-sdk` (same commit `5f3afea2fa`). The replace was likely added in anticipation of adopting Brian's expanded Actions API from the `feature/expanded-actions` branch, but that branch is untagged and unreleased. ### Why we can't just switch import paths The fork's `go.mod` on `feature/expanded-actions` still declares: ``` module codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2 ``` Go enforces that the declared module path must match the import path. This means: - **To use Brian's code** → we need a `replace` directive - **For `go install @latest` to work** → we need **no** `replace` directive These are mutually exclusive under Go's module system. ### Resolution **Immediate fix (this issue):** Remove the no-op `replace` directive. This unblocks `go install codeberg.org/goern/forgejo-mcp/v2@latest` with zero functional change, since the replace was pointing at identical code. **Follow-up:** Adopting Brian's expanded Actions API (which adds comprehensive Actions support for user/org/repo scopes) is blocked until his changes are merged upstream into `mvdkleijn/forgejo-sdk` and released. Brian offered to PR on [issue #84](https://codeberg.org/mvdkleijn/forgejo-sdk/issues/84) and the maintainer was receptive — just needs the PR to be filed.
Author
Owner

@redbeard @mvdkleijn — heads up: we're hitting this go install @latest blocker in forgejo-mcp because of a replace directive pointing at Brian's fork.

The immediate fix here is straightforward (remove the no-op replace), but longer-term we'd love to adopt the expanded Actions API from feature/expanded-actions. That's blocked until those changes land upstream in mvdkleijn/forgejo-sdk — I saw the positive exchange on mvdkleijn/forgejo-sdk#84. Is there anything we can do to help move that PR along?

@redbeard @mvdkleijn — heads up: we're hitting this `go install @latest` blocker in forgejo-mcp because of a `replace` directive pointing at Brian's fork. The immediate fix here is straightforward (remove the no-op replace), but longer-term we'd love to adopt the expanded Actions API from `feature/expanded-actions`. That's blocked until those changes land upstream in `mvdkleijn/forgejo-sdk` — I saw the positive exchange on [mvdkleijn/forgejo-sdk#84](https://codeberg.org/mvdkleijn/forgejo-sdk/issues/84). Is there anything we can do to help move that PR along?
goern self-assigned this 2026-02-06 19:30:36 +01:00

Like I said in mvdkleijn/forgejo-sdk#84 I'm down for someone shooting in a PR. I was planning to look at some outstanding PRs tomorrow in between other work.

Like I said in mvdkleijn/forgejo-sdk#84 I'm down for someone shooting in a PR. I was planning to look at some outstanding PRs tomorrow in between other work.
Author
Owner

Resolved by the Actions support work in ebe97a0 / af4636e.

The replace directive (pointing to redbeard/forgejo-sdk) is gone. We upgraded directly to codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2 v2.2.1-0.20260217203524-edf26081b649 — a pseudo-version of upstream main after SDK PR #103 was merged. No replace directive needed, so go install codeberg.org/goern/forgejo-mcp/v2@latest will work again once a release is tagged.

Resolved by the Actions support work in ebe97a0 / af4636e. The `replace` directive (pointing to `redbeard/forgejo-sdk`) is gone. We upgraded directly to `codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2 v2.2.1-0.20260217203524-edf26081b649` — a pseudo-version of upstream main after [SDK PR #103](https://codeberg.org/mvdkleijn/forgejo-sdk/pulls/103) was merged. No `replace` directive needed, so `go install codeberg.org/goern/forgejo-mcp/v2@latest` will work again once a release is tagged.
goern closed this issue 2026-02-18 14:44:58 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
goern/forgejo-mcp#67
No description provided.