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


#1

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.


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

    steps:
      - checkout

#3

Use this instead; it will work.

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

#4

Where do I specify the docker image?


#5

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


#6

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


#7

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.


#8

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…


#9

Sounds like you need to add your SSH keys;

https://circleci.com/docs/2.0/configuration-reference/#add_ssh_keys


#10

@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:


#11

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


#12

It works if I do this:

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

#13

It looks like a bug!


#14

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.


#15

@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.


#16

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


#18

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


#19