hashicorp / hashicorp/consul

Dependency conflict: github.com/armon/go-metrics vs github.com/hashicorp/go-metrics breaks downstream imports

Open
#22,838 2 comments 6 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
1d 18h
Merged PRs (30d)
39

Description

#### Overview of the Issue

The Consul repository imports `github.com/armon/go-metrics`, which has been renamed and moved to `github.com/hashicorp/go-metrics`. This causes conflicts and import issues downstream, especially when other dependencies require the new import path (`hashicorp/go-metrics`). For example, when integrating Consul with other libraries, Go's module system encounters ambiguities and requires manual replace directives, which do not always fully resolve the issues.

This breaks importing libraries such as [`github.com/mennanov/limiters`](https://github.com/mennanov/limiters). Attempting to import this library fails due to the conflicting metric library dependencies.

#### Reproduction Steps

1. Create a new Go project.
2. Run the following command:

```bash
go get github.com/mennanov/limiters@v1.13.3
```

3. Observe the following error:

```
go: github.com/mennanov/limiters imports
github.com/hashicorp/consul/api imports
github.com/hashicorp/serf/coordinate imports
github.com/hashicorp/go-metrics/compat imports
github.com/armon/go-metrics: github.com/armon/go-metrics@v0.5.4: parsing go.mod:
module declares its path as: github.com/hashicorp/go-metrics
but was required as: github.com/armon/go-metrics
```

### Consul info for both Client and Server

N/A (problem is with module resolution, not a running agent)

### Operating system and Environment details

- Go version: (reproducible with Go 1.21+)
- Any OS/Arch

### Log Fragments

N/A

### Notes

* The problem arises from a mismatch between `github.com/armon/go-metrics` and `github.com/hashicorp/go-metrics` in the dependency tree.
* Because of this, `limiters` cannot be imported without manual fixes.

### Request

Could this dependency be updated or fixed in Consul?
Any guidance on a workaround would be very helpful.

---

Thank you for your help!

Contributor guide

Open the contributing guide

Research direction

Start by tracing Consul's Go module dependency graph for both github.com/armon/go-metrics and github.com/hashicorp/go-metrics, then reproduce the failure with `go get github.com/mennanov/limiters@v1.13.3`. Done means the conflicting import path is resolved without manual replace directives and the reported downstream import succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.