cannot find package in any of GOROOT / GOPATH Go Origin: Application & API Last updated 4 Nov 2026

Go: cannot find package "github.com/pkg/errors" in any of: /usr/local/go/src/github.com/pkg/errors (from $GOROOT) /go/src/github.com/pkg/errors (from $GOPATH)

Go could not locate an imported package — it is not downloaded, the module is not initialised, or GOPATH mode is in effect.

Exact message you may see cannot find package in any of:cannot find package "github.com/pkg/errors" in any ofpackage is not in GOROOTpackage is not in stdcannot find package in any of GOROOT GOPATH
Seen on: Go

Meaning

In module mode run go mod init and go mod tidy (or go get pkg). The GOROOT/GOPATH wording means Go is running in legacy GOPATH mode (GO111MODULE=off or no go.mod). Ensure a go.mod exists in the project root and that GO111MODULE is not off.

Common causes

  • No go.mod in the project
  • GO111MODULE=off
  • Dependency not downloaded
  • Typo in the import path
  • Vendor directory out of date

⚡ Quick fix

  1. go mod init example.com/app && go mod tidy
  2. Unset GO111MODULE or set on
  3. go get github.com/pkg/errors

Detailed fix by platform

Go

  1. go env GO111MODULE GOFLAGS GOPATH shows the active mode

How to diagnose

  1. Mode — go.mod present?
  2. Env — GO111MODULE?
  3. Path — Import spelled right?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

go: updates to go.mod needed — Go: go: updates to go.mod needed; to update it: go mod tidy (Go)go: updates to go.mod…import cycle not allowed — Go: package app/models imports app/utils imports app/models: import cycle not allowed (Go)import cycle not allo…invalid version: unknown revision — Go: go: github.com/foo/bar@v1.2.3: invalid version: unknown revision v1.2.3 (Go)invalid version: unkn…listen tcp :8080: bind: address already in use — Go: listen tcp :8080: bind: address already in use (Go)listen tcp :8080: bin…missing go.sum entry — Go: missing go.sum entry for module providing package github.com/pkg/errors (imported by app); to add: go get app (Go)missing go.sum entryno required module provides package — Go: no required module provides package github.com/foo/bar; to add it: go get github.com/foo/bar (Go)no required module pr…sql: no rows in result set — Go: sql: no rows in result set (Go)sql: no rows in resul…terminal prompts disabled / 410 Gone (private module) — Go: fatal: could not read Username for 'https://github.com': terminal prompts disabled (Go)terminal prompts disa…cannot fi…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.