1

When trying to run godep save, I'm always getting the following error:

godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]:   Current Directory: /Users/username/Development/my-server
godep: [WARNING]:   $GOPATH: /Users/username/Development/my-server

Does anyone know how to solve this issue?

Welton122
  • 1,101
  • 2
  • 13
  • 28

1 Answers1

0

You want to make sure that you run this command from a repo that is also defined in your $GOPATH.

So it would need to be: /Users/username/gosource/src/github/foo/my-server/

This means that not only are all your packages located in your $GOPATH but additionally your own repo is located in your $GOPATH. At this point everything should work as expected.

If you don't have a $GOPATH environment variable defined you need to make sure it is set pre Go1.8.

Try this: echo $GOPATH at the command prompt to see if it's defined.

If not, you'll want to choose a location and set it with: export GOPATH=/your/final/location.

More details can be found here.

Ralph Caraveo
  • 10,025
  • 7
  • 40
  • 52
  • 2
    After changing my GOPATH to `/Users/username/gosource/src/github/foo/my-server/`, I'm still getting `godep should only be used inside a valid go package directory and godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.` – Welton122 May 01 '17 at 16:24