[checkout code] mkdir: cannot create directory ‘/go’: Permission denied


I’m trying to use executorType: machine with Go due to an issue with volume mounting with the executorType: docker. When I try to set my workDir to /go/src/github.com/projectorg/projectid I get this error:

mkdir: cannot create directory ‘/go’: Permission denied

This worked on the executorType: docker, so are the permissions different when using the executorType: machine?

I followed the GO examples in the 2.0 documentation, but it didn’t work.

version: 2
executorType: machine
      - image: golang:1.8.3
    working_directory: /go/src/github.com/test/example

      - checkout


Use this instead; it will work.

version: 2
    machine: true
    working_directory: ~/go/src/github.com/test/example
      - checkout


Where do I specify the docker image?


You don’t. You said you wanted the machine executor.


got it. I’ll give it a try. Thanks rohara!


Just to clarify:

You can run a Docker container, you just need to pull and run it manually. You can even log into a Docker registry to pull a private image. Docker is already running on the system and docker-compose is installed.


Thanks for the clarification @rohara! Now I got another error while fetching the GO dependencies:

#!/bin/bash -eo pipefail
go get -t -d -v ./...
github.com/docker/go-plugins-helpers (download)
github.com/coreos/go-systemd (download)
github.com/docker/go-connections (download)
Fetching https://golang.org/x/net/proxy?go-get=1
Parsing meta tags from https://golang.org/x/net/proxy?go-get=1 (status code 200)
get "golang.org/x/net/proxy": found meta tag main.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/proxy?go-get=1
get "golang.org/x/net/proxy": verifying non-authoritative meta tag
Fetching https://golang.org/x/net?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
golang.org/x/net (download)
github.com/org_name/repo_name (download)
# cd .; git clone https://github.com/org_name/repo_name /home/circleci/.go_workspace/src/github.com/org_name/repo_name
Cloning into '/home/circleci/.go_workspace/src/github.com/org_name/repo_name'...
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/org_name/repo_name/' 

This step was working before…


Sounds like you need to add your SSH keys;



@rohara it looks like there is a disconnect between the repo configuration and the build behavior as you can see it should be already using SSH:


Can you try starting the SSH agent?
I recommend rebuilding with SSH to log in and manually run commands to see what happens.


It works if I do this:

git config --global url."git@github.com:".insteadOf "https://github.com/"


It looks like a bug!


Good catch! It was HTTPS, not SSH. Making the switch to SSH does look like the widely accepted answer:

I am hesitant to file this as a bug since SSH works fine. One reason is you would need to navigate 2FA for most accounts using HTTPS anyway.


@rohara this behavior is not expected as it’s defined in the configuration that the deploy keys are preferred, so it should use SSH by default, not HTTPS.


That does make sense. Sorry :slight_smile: I opened up a bug report to change the default behavior.


thanks @rohara! I appreciate it, meanwhile I’m using the fix suggested above.