doctl: Errors when using Git for Windows

Doctl says unknown terminal, when trying doctl auth init: So, I have been using doctl on Windows via the Git Bash utility, powershell isn’t my thing. I download the doctl.exe to bin directory in my home folder. And invoke it using git bash CLI.

This used to work just fine till 1.36 but upon trying doctl auth init on a fresh Windows 10 install I am getting this error:

Ranvir@WestWind MINGW64 /
$ doctl auth init
Error: unable to read DigitalOcean access token: unknown terminal

This is easily circumvented using PowerShell, but with Git Bash the error is very annoying. Since this wasn’t an issue in previous releases, but is an issue now, I thought I will share it with everyone.

Hopefully, we aren’t relying on Windows’ underlying brokeness.

Environment: OS: Windows 10, 1909 up-to-date Arch: x86_64 doctl version 1.37.0-release (downloaded from GitHub releases page)

Additional Details: Using the --trace flag doesn’t print anything extra than what is mentioned above.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

Hey @sranvir, thanks for the report.

I’ve reproduced this with multiple versions of doctl now, so I wonder if it’s an issue with the Git Bash terminal. The issue happens here,

https://github.com/digitalocean/doctl/blob/884a996946e1691b2100877a075c7fdee902a843/commands/auth.go#L44-L46

Somehow, in Git Bash, it doesn’t think that standard output is a terminal. I also tried switching it to standard input, and using syscall.Stdout and syscall.Stdin, but the error still occurred.

Do you happen to know which version of doctl you were running when this worked?


As a workaround for Git Bash, you can run doctl auth init -t <YOUR_TOKEN>, which skips reading the token from the terminal.

Tried the command doctl auth init -t <token> ? Ben recommended it above, as a means to circumvent the issue for now.

@amartincolby Could you provide any further details about the failure you are seeing? I’ve tried to reproduce it, but I’ve been unable to do so.

A .gitlab-ci.yml file like this succeeds for me on gitlab.com:

before_script:
  - cd /root/ && wget https://github.com/digitalocean/doctl/releases/download/v1.46.0/doctl-1.46.0-linux-amd64.tar.gz
  - tar xf /root/doctl-1.46.0-linux-amd64.tar.gz
  - mv /root/doctl /usr/local/bin
  - doctl auth init --access-token $DO_TOKEN

test:
  script:
    - doctl account get

I also tried specifying the image you mentioned, but this also succeeds:

image: docker:latest

before_script:
  - cd /root/ && wget https://github.com/digitalocean/doctl/releases/download/v1.46.0/doctl-1.46.0-linux-amd64.tar.gz
  - tar xf /root/doctl-1.46.0-linux-amd64.tar.gz
  - mv /root/doctl /usr/local/bin
  - doctl auth init --access-token $DO_TOKEN

test:
  script:
    - doctl account get

Glad to see that I’m not the only one. I am having the same error with Gitlab CI/CD. I’m using the docker-in-docker image. Seems to be using docker:latest for the base image. This is a depressing failure for me since I’m running to doctl because Gitlab’s CI/CD into DO Kube is broken on Gitlab’s side for some reason. Doctl, you’re my only hope!

doctl auth init --context corona --access-token ${DO_TOKEN} fails. doctl auth init --access-token ${DO_TOKEN} fails. doctl auth init --context corona -t ${DO_TOKEN} fails. echo ${DO_TOKEN} | doctl auth init --context corona fails.

@sranvir No problem, thanks for the info! Our team is looking to see if there’s a better workaround for this, so I’ll leave this issue open and keep you updated on any progress we make.