Rushikesh Sabde
Rushikesh Sabde

Reputation: 1626

Getting "mkdir home/user permission denied" on go get command

I have set the following environmental variables in .bashrc file

    export GOROOT=/usr/local/go
    export PATH=$PATH:$GOROOT/bin
    export GOPATH=/home/Rushikesh/GO
    export PATH=$PATH:$GOPATH/bin

When I run following command:

    go get github.com/nsf/gocode

I get the following error:

    package github.com/nsf/gocode: mkdir /home/Rushikesh: permission denied

Upvotes: 4

Views: 6150

Answers (2)

Omkesh Sajjanwar
Omkesh Sajjanwar

Reputation: 863

Facing go: could not create module cache: mkdir /home/josh: permission denied issue in my Linux machine

RCA - invalid GOPATH in goenv

Solution -

Step 1

  • go to your working directory and enter following command

pwd

Copy the working directory

eg -
enter image description here

Step 2

sudo vi ~/.bashrc

paste following command in .bashrc file

export GOPATH="<your working directory or paste here the pwd output>"

eg - export GOPATH="/home/josh/workspace"

Step 3

source ~/.bashrc

Upvotes: 0

coolcoder
coolcoder

Reputation: 91

The problem is your configuration.

As reading form your comments Rushikesh is not user it is your directory. Then the GOPATH env variable should be

export GOPATH=/home/logged_user_name/Rushikesh/GO

Upvotes: 3

Related Questions