cli icon indicating copy to clipboard operation
cli copied to clipboard

`pscale auth login` only showing output after `ctrl+c` - not able to log in

Open aleksanderbrymora opened this issue 4 years ago • 7 comments

When running pscale auth login on WSL2 - Ubuntu, there is no output, nor redirect to any new windows for authentication. Output of the command only shows up after I cancel the execution of the command (by pressing ctrl + c) then it outputs (probably) the expected things:

pscale auth login
^CFailed to open a browser: signal: interrupt

Confirmation Code: YMHOSZCP

If something goes wrong, copy and paste this URL into your browser: https://auth.planetscale.com/oauth/device?user_code=YMHOSZCP

Error: error performing http request: Post "https://auth.planetscale.com/oauth/token": context canceled

When I do try the provided URL it does surprisingly redirect me to the confirmation page with the code, where I can accept it. When I do, it does go through, but obviously this token is not active anymore so the auth in the pscale cli does not register me as logged in.

I did upgrade all the packages in ubuntu I downloaded and installed the newest release of the cli I gave it quite a long time to run

aleksanderbrymora avatar Jan 19 '22 16:01 aleksanderbrymora

Thanks for reporting, we'll look into this!

iheanyi avatar Jan 22 '22 21:01 iheanyi

How did you get pscale CLI installed in WSL?

EDIT: ah never mind, I figured out to download the .deb file in windows from github, drag it over into my WSL directory and install using dpkg.

stephanlamoureux avatar Feb 14 '22 05:02 stephanlamoureux

Just to be thorough I used these instructions. I used wget to grab the latest release and followed the rest of the instructions. And yeah, the issue is still present and behaves in the same way, as described above. Let me know if I can be of any more help.

aleksanderbrymora avatar Feb 14 '22 11:02 aleksanderbrymora

Facing this as well.

ansh avatar May 14 '22 01:05 ansh

Me too, for more context : I installed the CLI in WSL by downloading the deb from the releases with wget and using dpkg -i.

lelabo-m avatar Aug 09 '22 16:08 lelabo-m

Hello, I tried this today and it worked no problem, unless there is any objection I think this can be closed.

aduarterengifo avatar Sep 16 '22 14:09 aduarterengifo

Tried it a week ago and it was still not working... Unless you changed anything, I doubted it's fixed.

lelabo-m avatar Sep 17 '22 10:09 lelabo-m

For me at least this seemed to be caused by xdg-open which would hang no matter what I tried to do with it. Figured I'd reinstall it to see if anything would change, but simply leaving xdg-utils uninstalled fixed the issue for me (I have no other use for it).

kettui avatar Oct 12 '22 09:10 kettui

Still encountering this as well, any news on a fix?

callum-gander avatar Nov 09 '22 14:11 callum-gander

It might be a different problem, but when I used on WSL I could only make it work when I used pscale with sudo. Without sudo, it was hanging for quite long and then showed that it was not able to write access tokens to the filesystem.

jihoon416 avatar Dec 24 '22 05:12 jihoon416

I face this problem to. using WSL 2. it's not showing anything.

This is my machine, and I download pscale_0.126.0_linux_amd64.deb

Linux RioChndr-Lenovo-Legion 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

RioChndr avatar Jan 03 '23 07:01 RioChndr

I experience similar issues on WSL2 (Ubuntu):

I manually open the browser window, confirm, and I'm met with the following error. Can I get the output of the access-token so that I can atleast write this file manually?

Thanks in advance

ridds@DESKTOP-5PLDNPK:~$ sudo pscale auth login
[sudo] password for ridds:
Failed to open a browser: xdg-open resolves to executable in current directory (./xdg-open)

Confirmation Code: 97V4NKKI

If something goes wrong, copy and paste this URL into your browser: https://auth.planetscale.com/oauth/device?user_code=97V4NKKI

Error: error logging in: error writing token: open /root/.config/planetscale/access-token: no such file or directory```

blakecannell avatar Jan 27 '23 09:01 blakecannell

@blakecannell I'm in almost the same environment.The following methods work well.

$ sudo mkdir -p /root/.config/planetscale

$ sudo pscale auth login
Confirmation Code: <CODE>

If something goes wrong, copy and paste this URL into your browser: https://auth.planetscale.com/oauth/device?user_code=<CODE>

Successfully logged in.

motty93 avatar Jan 29 '23 12:01 motty93

https://github.com/planetscale/cli/issues/449#issuecomment-1407645556 With the super user's access token saved, pscale can be run without the sudo by doing the following.

$ mkdir $HOME/.config/planetscale

$ sudo cp /root/.config/planetscale/* $HOME/.config/planetscale

$ sudo chown $USER:$USER $HOME/.config/planetscale/*

$ pscale database create sample

$ pscale database list
  NAME            CREATED AT      UPDATED AT      NOTES
 --------------- --------------- --------------- -------
  sample   5 minutes ago   4 minutes ago

You can get a list of planetscale databases.

If the access token has expired, you will need to sudo pscale auth login again and copy the access-token.

motty93 avatar Jan 30 '23 00:01 motty93

I was facing the same problem, even as root with sudo command but I fixed:

Just create the planetscale folder before do auth:

mkdir ~/.config/planetscale
pscale auth login

EdMaxi avatar Feb 04 '23 18:02 EdMaxi

I was facing the same problem, even as root with sudo command but I fixed:

Just create the planetscale folder before do auth:

mkdir ~/.config/planetscale
pscale auth login

this worked, thanks!

KModestas avatar Feb 10 '23 15:02 KModestas

I've faced this issue today on a fresh Amazon Linux server when installing pscale. It appears the auth directory is not created for the user, when it tries to write the access-token file it fails:

$ sudo rpm -i https://github.com/planetscale/cli/releases/download/v0.138.0/pscale_0.138.0_linux_amd64.rpm
$ pscale login
Failed to open a browser: exec: "xdg-open": executable file not found in $PATH

Confirmation Code: <redacted_code>

If something goes wrong, copy and paste this URL into your browser: https://auth.planetscale.com/oauth/device?user_code=<redacted_code>

Error: error logging in: error writing token: open /home/ec2-user/.config/planetscale/access-token: no such file or directory

Once I created the directory from the error message above, I was able to login successfully.

$ ls /home/ec2-user/.config/planetscale/
ls: cannot access '/home/ec2-user/.config/planetscale/': No such file or directory

$ mkdir -p /home/ec2-user/.config/planetscale/

$ pscale login
Failed to open a browser: exec: "xdg-open": executable file not found in $PATH

Confirmation Code: <redacted_code>

If something goes wrong, copy and paste this URL into your browser: https://auth.planetscale.com/oauth/device?user_code=<redacted_code>

Successfully logged in.

FancyFane avatar Apr 26 '23 17:04 FancyFane

This should now be fixed with the change in https://github.com/planetscale/cli/pull/670

mscoutermarsh avatar Apr 28 '23 20:04 mscoutermarsh