Closed arpadgabor closed 1 year ago
This is a duplicate of https://github.com/supabase/cli/issues/819
Actually, I'm not sure it's really a duplicate, but possibly related. supabase login
worked just fine, link
however does not. I see in the source it's also trying to use the DB_PASSWORD
env, but seems like it's missing it.
https://github.com/supabase/cli/blob/6592db582bcf1880400f3a04c7daaa099e53fe84/cmd/link.go#L23-L27
I'm trying to add the password like
DB_PASSWORD=xyz supabase link --project-ref=abc
# or with
export DB_PASSWORD=xyz
...
but it's still prompting me for the password, and it still hangs. So I think the issue is somewhere else.
All our envs are prefixed with SUPABASE
. Can you give SUPABASE_DB_PASSWORD
a try? I will reopen this for now.
It would also be helpful if you can share with us the logs after running with --debug
flag
All our envs are prefixed with SUPABASE
Ah okay. Tried now also with --debug
but I'm getting nothing. However what I did find out is that if I run it outside my project it continues the process and then fails with
Error: cannot read config in /home/arpad/work: open supabase/config.toml: no such file or directory
Have you set up the project with supabase init?
Which is expected. But when running again in the project, it hangs with no logs.
✦ ❯ SUPABASE_DB_PASSWORD=abc supabase link --project-ref=xyz --debug
# nothing happening
Finally got to some logs after specifying database password and access token as environment variables.
2023/03/01 17:55:21 DNS Start: {Host:api.supabase.com}
2023/03/01 17:55:21 DNS Done: {Addrs:[{IP:213.188.196.91 Zone:} {IP:2a09:8280:1:b2b4:dad3:3383:ae8f:b96a Zone:}] Err:<nil> Coalesced:false}
2023/03/01 17:55:21 Connect Start: tcp 213.188.196.91:443
2023/03/01 17:55:21 Connect Done: tcp 213.188.196.91:443
2023/03/01 17:55:21 TLS Start
2023/03/01 17:55:21 TLS Done: {Version:772 HandshakeComplete:true DidResume:false CipherSuite:4865 NegotiatedProtocol:h2 NegotiatedProtocolIsMutual:true ServerName:api.supabase.com PeerCertificates:[0xc0003c0b00 0xc0003c1080 0xc0003c1600] VerifiedChains:[[0xc0003c0b00 0xc0003c1080 0xc000855600]] SignedCertificateTimestamps:[] OCSPResponse:[] TLSUnique:[] ekm:0x638780}
2023/03/01 17:55:21 Sent Header: :authority [api.supabase.com]
2023/03/01 17:55:21 Sent Header: :method [GET]
2023/03/01 17:55:21 Sent Header: :path [/v1/projects/olznnnxatjwapkijkjli/postgrest]
2023/03/01 17:55:21 Sent Header: :scheme [https]
2023/03/01 17:55:21 Sent Header: authorization [Bearer sbp_92948466e045a533648a6c87b426a4b9fcf06c37]
2023/03/01 17:55:21 Sent Header: user-agent [SupabaseCLI/1.40.4]
2023/03/01 17:55:21 Sent Header: accept-encoding [gzip]
2023/03/01 17:55:21 Send Done
2023/03/01 17:55:21 Recv First Byte
2023/03/01 17:55:21 Connect Start: udp 172.29.96.1:53
2023/03/01 17:55:21 Connect Start: udp 172.29.96.1:53
2023/03/01 17:55:21 Connect Done: udp 172.29.96.1:53
2023/03/01 17:55:21 Connect Done: udp 172.29.96.1:53
2023/03/01 17:55:21 Connect Start: udp 172.29.96.1:53
2023/03/01 17:55:21 Connect Start: udp 172.29.96.1:53
2023/03/01 17:55:21 Connect Done: udp 172.29.96.1:53
2023/03/01 17:55:21 Connect Done: udp 172.29.96.1:53
2023/03/01 17:55:22 Connect Start: tcp 3.64.193.111:6543
2023/03/01 17:55:22 Connect Done: tcp 3.64.193.111:6543
2023/03/01 17:55:22 PG Send: {"Type":"StartupMessage","ProtocolVersion":196608,"Parameters":{"database":"postgres","user":"postgres"}}
2023/03/01 17:55:22 PG Recv: {"Type":"AuthenticationSASL","AuthMechanisms":["SCRAM-SHA-256"]}
2023/03/01 17:55:22 PG Send: {"Type":"SASLInitialResponse","AuthMechanism":"SCRAM-SHA-256","Data":"n,,n=,r=ONRrtx9/1Rnh+/FQSl7RA1AT"}
2023/03/01 17:55:22 PG Recv: {"Type":"AuthenticationSASLContinue","Data":"r=ONRrtx9/1Rnh+/FQSl7RA1ATOL2DauC10Fn2AT9MUICjY+gV,s=uIVLT8zy02Sk5G18OwDOlw==,i=4096"}
2023/03/01 17:55:22 PG Send: {"Type":"SASLResponse","Data":"c=biws,r=ONRrtx9/1Rnh+/FQSl7RA1ATOL2DauC10Fn2AT9MUICjY+gV,p=tHcS+zpSuiEftEXDO5jwGhmODsr6xWTppW1YdjBb6fI="}
2023/03/01 17:55:22 PG Recv: {"Type":"AuthenticationSASLFinal","Data":"v=9JzE4o4XK1816TJ+WJcZ+4OUQnb72/i/E7YMt8w//gc="}
2023/03/01 17:55:22 PG Recv: {"Type":"AuthenticationOK"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"default_transaction_read_only","Value":"off"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"in_hot_standby","Value":"off"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"integer_datetimes","Value":"on"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"IntervalStyle","Value":"postgres"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"is_superuser","Value":"off"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"server_encoding","Value":"UTF8"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"server_version","Value":"15.1"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"session_authorization","Value":"postgres"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"client_encoding","Value":"UTF8"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"DateStyle","Value":"ISO, MDY"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"TimeZone","Value":"UTC"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"standard_conforming_strings","Value":"on"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParameterStatus","Name":"application_name","Value":""}
2023/03/01 17:55:22 PG Recv: {"Type":"BackendKeyData","ProcessID":431671472,"SecretKey":1385061276}
2023/03/01 17:55:22 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"}
2023/03/01 17:55:22 PG Send: {"Type":"Parse","Name":"","Query":"CREATE SCHEMA IF NOT EXISTS supabase_migrations","ParameterOIDs":null}
2023/03/01 17:55:22 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2023/03/01 17:55:22 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2023/03/01 17:55:22 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2023/03/01 17:55:22 PG Send: {"Type":"Parse","Name":"","Query":"CREATE TABLE IF NOT EXISTS supabase_migrations.schema_migrations (version text NOT NULL PRIMARY KEY)","ParameterOIDs":null}
2023/03/01 17:55:22 PG Send: {"Type":"Bind","DestinationPortal":"","PreparedStatement":"","ParameterFormatCodes":null,"Parameters":[],"ResultFormatCodes":[]}
2023/03/01 17:55:22 PG Send: {"Type":"Describe","ObjectType":"P","Name":""}
2023/03/01 17:55:22 PG Send: {"Type":"Execute","Portal":"","MaxRows":0}
2023/03/01 17:55:22 PG Send: {"Type":"Sync"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParseComplete"}
2023/03/01 17:55:22 PG Recv: {"Type":"BindComplete"}
2023/03/01 17:55:22 PG Recv: {"Type":"NoData"}
2023/03/01 17:55:22 PG Recv: {"Severity":"NOTICE","SeverityUnlocalized":"NOTICE","Code":"42P06","Message":"schema \"supabase_migrations\" already exists, skipping","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"schemacmds.c","Line":128,"Routine":"CreateSchemaCommand","UnknownFields":null}
2023/03/01 17:55:22 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE SCHEMA"}
2023/03/01 17:55:22 PG Recv: {"Type":"ParseComplete"}
2023/03/01 17:55:22 PG Recv: {"Type":"BindComplete"}
2023/03/01 17:55:22 PG Recv: {"Type":"NoData"}
2023/03/01 17:55:22 PG Recv: {"Severity":"NOTICE","SeverityUnlocalized":"NOTICE","Code":"42P07","Message":"relation \"schema_migrations\" already exists, skipping","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"parse_utilcmd.c","Line":209,"Routine":"transformCreateStmt","UnknownFields":null}
2023/03/01 17:55:22 PG Recv: {"Type":"CommandComplete","CommandTag":"CREATE TABLE"}
2023/03/01 17:55:22 PG Recv: {"Type":"ReadyForQuery","TxStatus":"I"}
2023/03/01 17:55:22 PG Send: {"Type":"Terminate"}
Failed to save database password: Failed to activate service 'org.freedesktop.secrets': timed out (service_start_timeout=120000ms)
Finished supabase link.
It looks like it succeeded, but does that timeout mean I always have to add those environment variables to run commands?
I had same issue in WSL2. Most likely you have WSLg (some GUI linux app) installed, which leads to some Gnome password (gnome keyring) manager which is actually leading to this command hanging. What happens actually is UI popup to unlock vault is not appearing in Windows and it looks like command is hanging and you are not able to kill it.
In order to avoid this I actually use one distro without GUI apps which leads to supabase to use dotfiles to store credentials and everything works like on OSX or real Linux.
You can try top
to find and kill gnome keyring by ID and it should start just fine next time you exec supabase link, but on next call you end up with same issue.
During my research I bumped into https://stackoverflow.com/questions/72528100/how-to-unlock-gnome-keyring-on-debian-headless-wsl-2-and-make-it-work-in-pytho and many more essentially leading to same problem.
Yeah I do have WSLg set up. Will check what you linked and report back if I find anything worthwhile.
I am currently having a similar problem when linking a project, I get this error.
Failed to save database password: failed to unlock correct collection '/org/freedesktop/secrets/collection/login'
I use Linux Mint 21 Vanessa (based on ubuntu jammy).
Also having this issue on WSL 2 with Ubuntu distro on Windows 11... any solution? I can't link my supabase projects 😔
@djordje What distro do you have this working on?
UPDATE: Seems to happen regardless of distro. I've tried with Ubuntu, Red Hat flavor and Mint with same result.
Also having this issue on WSL 2 with Ubuntu distro on Windows 11... any solution? I can't link my supabase projects 😔
@djordje What distro do you have this working on?
UPDATE: Seems to happen regardless of distro. I've tried with Ubuntu, Red Hat flavor and Mint with same result.
I use latest Ubuntu, but I had to create new WSL2 distro and avoid any GUI apps to avoid WSLg. Works fine for me.
I managed to get it working by disabling wslg https://x410.dev/cookbook/wsl/disabling-wslg-or-using-it-together-with-x410/
On Ubuntu, ran into this issue, ran top
and gnome-shell was running, and would keep restarting even if I killed the process.
Solution
sudo service gdm stop
-> Everything works.
If you are on WSL and came to this issue by searching for Failed to save database password: failed to unlock correct collection '/org/freedesktop/secrets/collection/login'
then,
gnome-keyring
sudo apt purge gnome-keyring
sudo apt autoremove
.wslconfig
in %USERPROFILE%
and add below content
[wsl2]
guiApplications=false
wsl --shutdown
gnome-keyring
again
sudo apt update
sudo apt install gnome-keyring
If you are on WSL and came to this issue by searching for
Failed to save database password: failed to unlock correct collection '/org/freedesktop/secrets/collection/login'
then,
- Uninstall
gnome-keyring
sudo apt purge gnome-keyring sudo apt autoremove
- Disable wslg by creating
.wslconfig
in%USERPROFILE%
and add below content[wsl2] guiApplications=false
- Shutdown wsl and again start
wsl --shutdown
- Install
gnome-keyring
againsudo apt update sudo apt install gnome-keyring
I followed these instructions and still run into this error
Failed to save database password: failed to unlock correct collection '/org/freedesktop/secrets/aliases/default'
@Tortillaguy this should work as I dont see the need to save the password locally
It doesn't work no matter what I do , I killed gnome-keystring first and then uninstalled it but it was still not working. If you have it , its one problem , if you don't have it its another problem. I added my db password to env file as well , it still didn't work.
Were you able to fix it @Tortillaguy
Apologies for the delay in addressing this issue. I will add some special handling for WSL in the next stable release so that the cli works more nicely out of the box.
Having the same issue on WSL2:
Connecting to remote database...
Failed to save database password: Keyring is not supported on WSL
Finished supabase link.
Tried both supabase link --project-ref xx
and supabase link --project-ref xx --password xx
.
Using latest supabase CLI (installed just now for the first time).
Tried all of the suggested fixes in this thread:
SUPABASE_DB_PASSWORD
env variablegnome-keyring
guiApplications
via .wslconfig
Nothing works. Am completely blocked.
Edit: Strangely, despite the error shown above, supbase db pull
works fine and seems to pull the remote DB migrations correctly. I wasted a saturday morning trying to get around this error.
Bug report
Describe the bug
Installed
supabase
using homebrew and I'm trying to link my local project. After inserting the database password and hitting enter, the process hangs and I can't do anything else. Ctrl + C does not work either. Any password I add and it just hangs, even if it's correct or not. I also tried restarting the project but got the same behavior.To Reproduce
supabase link --project-ref=abc
Expected behavior
Command should continue and show error/sucess.
Screenshots
It just hangs like this forever.
System information
Additional context
n/a