charmbracelet / charmbracelet/bubbletea

Replace directive in examples/go.mod breaks 'go run charm.land/.../examples/...@latest'

Open
#1,681 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
44.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

It doesn't seem to be possible to `go run` the examples with their fully qualified paths.

**Setup**

Gentoo/bash/konsole, though this should have no effect since no charm.land code is running.

**To Reproduce**

```console
$ go version
go version go1.26.1 linux/amd64
$ go run charm.land/bubbletea/examples/doom-fire@latest
go: charm.land/bubbletea/examples/doom-fire@latest (in charm.land/bubbletea/examples@v0.0.0-20260420134506-074596e14e2f):
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.
```
I tried some slightly different commands, to no avail:
```console
$ go run charm.land/bubbletea/v2/examples/doom-fire@latest
go: downloading charm.land/bubbletea/v2 v2.0.6
go: charm.land/bubbletea/v2/examples/doom-fire@latest: module charm.land/bubbletea/v2@latest found (v2.0.6), but does not contain package charm.land/bubbletea/v2/examples/doom-fire
$ go run charm.land/bubbletea/examples/v2/doom-fire@latest
go: charm.land/bubbletea/examples/v2/doom-fire@latest: module charm.land/bubbletea/examples@latest found (v0.0.0-20260420134506-074596e14e2f), but does not contain package charm.land/bubbletea/examples/v2/doom-fire
```
I _can_ run the downloaded version from `$GOPATH/pkg/mod`, _if_ I'm in a module importing bubbletea, but seemingly not othewise. A bit strange, though (IMO) not important enough to dig into and unlikely to be related to the main issue.

```console
$ go run ~/go/pkg/mod/charm.land/bubbletea/examples\@v0.0.0-20260420134506-074596e14e2f/doom-fire/main.go

```

**Source Code**
I used the doom-fire example, though any should suffice.

**Expected behavior**
Ideally, the examples can be run with `go run charm.land/` rather than needing to `git clone charm.land/bubbletea; cd bubbletea/examples; go run ./`

However, from the error message it seems necessary to remove the `replace` directive to make it work.

Slightly related (also mentions replace directive): #16

Contributor guide

Open the contributing guide

Research direction

Start with examples/go.mod and reproduce the failure using go run charm.land/bubbletea/examples/doom-fire@latest. Investigate how the replace directive affects running the examples as fully qualified packages, and verify that the examples can be run without cloning the repository or importing bubbletea from another module.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
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.