Can't clone private gogs repository in 1.0.0-rc.4: No such device or address

Hello! I’ve been wanting to upgrade to 1.0.0-rc.4 and tried to change everything accordingly like adding DRONE_GIT_USERNAME and DRONE_GIT_PASSWORD with a set of credentials I created for drone in Gogs and toggling DRONE_GIT_ALWAYS_AUTH=true. I’m still getting this however:

Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/master:
fatal: could not read Username for 'https://git.mydomain.com': No such device or address 

Maybe it’s something related to using HTTPS instead of SSH, which I’m avoiding since Gogs recommends using HTTPS when using its docker image.

Previously, I used drone 0.6.x, and it did work, but I’m not looking forward into downgrading.

I looked into the sqlite database and saw that the repository wasn’t marked as private, so I did it manually (updating the row to have repo_private = 1 and repo_visilibity = private) but still no luck. I may be missing some environment variable, I currently have these set:

DRONE_SERVER_PROTO=https
DRONE_SERVER_HOST=ci.mydomain.com
DRONE_GOGS_SERVER=https://git.mydomain.com
DRONE_RUNNER_CAPACITY=2
DRONE_GIT_ALWAYS_AUTH=true
DRONE_GIT_USERNAME=drone
DRONE_GIT_PASSWORD=hunter2

I’m also running it on single-machine, I don’t know if running a drone-runner instead would work.

Ah, and gogs is 0.11.79, I updated it to the latest, just in case.

Have you searched the existing threads for this error?
http://discuss.harness.io/search?q=No%20such%20device%20or%20address

Yes, I have, this was probably the most helpful: Another 'could not read username' when cloning question: Gogs/Drone, and indeed, the repository was marked as public when it should’ve been marked as private.

However, some things have changed especially on the environment variables front, and I’m afraid some of it no longer applies (like the DRONE_GOGS_PRIVATE_MODE doesn’t seem to exist anymore for example).

Private mode was deprecated in favor of DRONE_GIT_ALWAYS_AUTH=true

When always auth is true it will instruct Drone to always clone the repository with credentials, regardless of whether or not the repository is private.

Very interesting. I have that toggled in my environment variables:

But it seems like it doesn’t even attempt to login using my provided credentials DRONE_GIT_USERNAME and DRONE_GIT_PASSWORD in Gogs (hence this error). I’m thinking that what causes this problem is my single machine setup :confused: .

Update: The same happens if I have one agent, so unrelated I guess.

could not read Username for ‘https://git.mydomain.com’: No such device or address

Please read this Stackoverflow post: git - GitHub - fatal: could not read Username for 'https://github.com': No such file or directory - Stack Overflow

You will notice that Git will return this error under a variety of circumstances, which may not have anything to do with the actual username or password.

It is more likely that Drone simply cannot reach your Gogs server because you are using custom Docker networks and Docker internal DNS, and the clone container is running on a completely separate Docker network.

You should be able to test all of this manually:

kind: pipeline
name: default

clone:
  disable: true

steps:
- name: custom_clone
  image: docker:git
  commands:
  - git clone https://username:password@git.mydomain.com/foo/bar.git
1 Like

And case closed, looks like gogs didn’t set the password correctly for the account I created. If someone else wants to debug this, I recommend setting up your .drone.yml like this:

clone:
  disable: true

steps:
  - name: clone
    image: docker:git
    commands:
      - echo $DRONE_REPO_PRIVATE
      - cat /root/.netrc
      - git clone $DRONE_GIT_HTTP_URL
2 Likes

Yea, the error message is quite worthless, but thanks for the help anyway!

How could I handle this circumstance?Change Docker networks?

You can use this command to check if the git username and password are returned correctly:

curl -i -H ‘X-Drone-Token: YOUR_RPC_SECRET’ -H ‘content-type: application/json’ -X POST -d ‘{“Repo”: YOUR_REPO_ID}’ YOUR_SERVER_PROTO://YOUR_DRONE_HOST/rpc/v1/netrc

if DRONE_REPO_PRIVATE env return false, means your repo on gogs was not privated
even though you go back to your repo and set privated it still doesn’t work, and i found drone cache all repo infomation on its database which is database.sqlite

  • find the repo id through wehbook info
  • update table repo set repo_private=1 and it works