# Fix "module declares its path as: github.com/sirupsen/logrus" in a Go Project

Yes. An agent renames the capitalised Sirupsen/logrus import, adds a go.mod, builds, and checks the logger still behaves after years of releases.

[Run this on Rush](https://cloud.getrush.ai/run/fix-logrus-module-path-mismatch/logrus/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The capitalisation of the logrus author's GitHub user name changed, and the module now declares itself as `github.com/sirupsen/logrus`. Code that imports the old spelling, `github.com/Sirupsen/logrus`, builds nowhere with Go modules: `go mod tidy` stops with `parsing go.mod: module declares its path as: github.com/sirupsen/logrus but was required as: github.com/Sirupsen/logrus`. zheng-ji/goTcpProxy is a small TCP proxy from the GOPATH era that shows the whole path to that message. It is six Go files in package `main`, has no `go.mod` and no vendor directory, and its README says to clone it into `$GOPATH` and run `make`, which is `go build .`.

The agent reproduces the failure in order. On a current toolchain `go build .` first reports `go.mod file not found in current directory or any parent directory`. After `go mod init` with the repository's import path, `go mod tidy` resolves the two other dependencies, `stathat.com/c/consistent` in `balancer.go` and `launchpad.net/goyaml` in `config.go`, and then fails on logrus with the path mismatch. The capitalised import appears twice, on line 8 of `main.go` and line 6 of `log.go`. The agent changes both to lowercase, runs `go mod tidy` again, and `go build .` produces a binary.

A clean build is where the easy version of this fix stops, and it is not enough. The repository's last commit is from 2016 and it pinned nothing, so the rename also moves logrus forward by every release since. The agent reads how the code uses the library. `log.go` builds its logger as a struct literal, `&logrus.Logger{Out: file, Level: level, Formatter: new(logrus.JSONFormatter)}`, without calling `logrus.New()`, and `proxy.go` calls `pLog.Fatal` on a listen error. With no test files in the repository, it writes a short test that constructs a logger the same way, logs one line and checks the JSON fields, then confirms a `Fatal` call still exits with status 1.

It also runs `go vet ./...`, which prints one finding unrelated to logrus: `main.go:23:2: misuse of unbuffered os.Signal channel as argument to signal.Notify`. The agent reports it and leaves the line alone, along with the `launchpad.net/goyaml` import, an address from before the YAML package moved to `gopkg.in`. Both go into the pull request as follow-ups. It updates the README's build instructions, since cloning into `$GOPATH` is no longer needed once `go.mod` exists.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "This Go project fails to build with \"module declares its path as: github.com/sirupsen/logrus but was required as: github.com/Sirupsen/logrus\". Reproduce it first and record each error in the order it appears; if the project has no go.mod, create one with the repository's import path and run go mod tidy. Find every import of github.com/Sirupsen/logrus in this repository and change it to github.com/sirupsen/logrus, including in vendored or generated files that are checked in. Then run go mod why on the capitalised path. If one of our dependencies still imports the capitalised path, upgrade that dependency to a version that uses the lowercase path; only if none exists, add a replace directive and explain why. Do not pin logrus to an old version to avoid the error. Once it builds, check that the logrus version you ended up with still behaves the way this code expects: read how loggers are constructed and which formatters, hooks and levels are used, and write a small test for that if the project has none. Run go build ./..., go vet ./... and go test ./..., and include the output. Report vet findings and other outdated import paths as follow-ups without fixing them. Update build instructions in the README if they no longer match. Open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that adds `go.mod` and `go.sum`, changes one import line in each file that named the old path, adds a test file for the logger, and edits a few lines of the README. The description lists the errors in the order a newcomer meets them, the missing `go.mod` and then the path mismatch, with the command that produced each, followed by the output of `go build ./...`, `go vet ./...` and `go test ./...` after the change.

It states which logrus version `go mod tidy` selected and what the agent verified against it: that a logger built as a struct literal still writes JSON lines with `level`, `msg` and `time`, and that `Fatal` still terminates the process. That paragraph is the reviewer's main reading, because the import rename is mechanical and the version jump is where behaviour could have moved.

Follow-ups are listed separately: the `signal.Notify` finding from `go vet` with its file and line, and the old YAML import path. Before merging, the reviewer confirms that no file still contains the capitalised path, that `go.mod` has no `replace` line unless the description justifies one, and that the `go` directive names a version their build machines have.

## Run it on every repository that still imports the old path

An organisation that wrote Go before modules tends to have this import in many small services at once. Search your code host for `github.com/Sirupsen/logrus`, and for each repository that matches send `POST /o/{org}/sessions` with the body above and that repository as the resource. Include a `request_id` that is a UUID v5 of the repository name, so running the script a second time returns the runs it already started instead of starting duplicates.

There is no need to pace the script. A key runs at most its `max_concurrent` runs at once, and a request past that still answers `202` with `status: "queued"` and starts when a slot frees. If the key has a `webhook_url`, each run it starts posts `run.completed` or `run.failed` there when it finishes, so the script can exit and a small handler can collect the pull request links.

## Why run it on Rush?

Repositories with this error are old, and old Go code rarely fails only once. The build stops on the missing `go.mod`, then on the path, and after that the code is compiled against a logging library several years newer than the one it was written for. Working through that takes a clean module cache and a toolchain nobody has to reconfigure. The sandbox provides both, and the session keeps each command with its output, so the order of failures in the pull request is the order they really occurred.

It is also the kind of fix where a wrong shortcut looks identical to a right one from the outside. Pinning an ancient logrus or adding a `replace` line both make the error disappear. The prompt rules out the first and requires a reason for the second, and the agent has to show `go mod why` output to justify it. A reviewer gets a diff plus the evidence for each choice, not a green build with a hidden pin.

## Frequently asked questions

### I changed my imports and still get the error. Why?

One of your dependencies imports the capitalised path. `go mod why github.com/Sirupsen/logrus` names it. Upgrade that dependency to a release that uses the lowercase path, which most maintained libraries have long since published.

### Does a replace directive fix it?

It can. On goTcpProxy, a `replace` line pointing `github.com/Sirupsen/logrus` at a tagged version of the lowercase module builds without touching the source. It leaves both spellings in `go.mod`, so treat it as a stopgap for a dependency you cannot upgrade, never as the fix for your own imports.

### What is the case-insensitive import collision error?

It is the same problem seen from the other side: two packages in one build import logrus under different capitalisations, and Go refuses to compile paths that differ only by case. The cure is the same, one spelling everywhere, starting with whichever dependency `go mod why` points to.

### Will my log output change after the upgrade?

The rename itself changes nothing, but it usually arrives with a large version jump. The agent tests the formatter and levels your code actually uses and reports what it checked. If you parse these logs downstream, compare one real line before and after as part of review.

## More logrus jobs

- [Migrate From Logrus to log/slog in a Go CLI](https://getrush.ai/run/migrate-logrus-to-slog/logrus/)

## More jobs like this: Fix a bug from an alert

- [Fix "ImportError: lxml.html.clean module is now a separate project lxml_html_clean"](https://getrush.ai/run/fix-lxml-html-clean-separate-project-import-error/lxml/)
- [Fix "TypeError: marked is not a function" After Upgrading marked](https://getrush.ai/run/fix-marked-is-not-a-function/marked/)
- [Fix "cannot import name 'soft_unicode' from 'markupsafe'"](https://getrush.ai/run/fix-markupsafe-soft-unicode-import-error/markupsafe/)
- [Fix "AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap'" on Matplotlib 3.9](https://getrush.ai/run/fix-matplotlib-cm-get-cmap-attribute-error/matplotlib/)
- [Fix "TypeError: Missing parameter name at 1" After Upgrading to Express 5](https://getrush.ai/run/fix-missing-parameter-name-at-1/path-to-regexp/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
