dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Running `dolt sql-server` creates an empty `.doltcfg` directory. Potential UX issue.

Open timsehn opened this issue 1 year ago • 6 comments

This in and of itself is not an issue but can create a confusing first hour experience issue.

Let's say I make a dolt directory and database directory like so:

mkdir ~/databases/dolt
cd ~/databases/dolt

Then I run dolt sql-server. I get a .doltcfg directory like so:

~/databases/dolt/.doltcfg

Now, if I go up a directory, maybe I want multiple databases:

cd ~/databases/
dolt sql-server

I get another .doltcfg directory

~/databases/.doltcfg

Now if I go back to cd ~/databases/dolt and run dolt sql-server. I get this error:

Failed to start server. Bad Configuration
multiple .doltcfg directories detected: '/Users/timsehn/databases/.doltcfg' and '/Users/timsehn/databases/dolt/.doltcfg'; pass one of the directories using option --doltcfg-dir

Note, I have no idea what these directories are for and they are both empty.

I see a couple potential solutions/improvements.

  1. Only write this directory when you actually need to write in it, not every time I run dolt sql-server.
  2. Don't print the above error if both directories are empty, if you have to write, write to the one you would have if none existed.
  3. Set some sort of order of preference here. Maybe always prefer the .doltcfg in the directory the server is being run in and fall back to the directory above?

timsehn avatar Jul 21 '22 16:07 timsehn

The .doltcfg is meant to hold all the different files that contain data we want to persist for a server. Right now, it only holds the privileges.db file. privileges.db is only create when you make a new user or modify users/grants in some way.

I could work on a change so that the .doltcfg directory is only made when something is changed.

I'm not sure about points 2 and 3, as defaulting to reading/writing to one of the directories could resulting in different behavior depending on where you run dolt sql or dolt sql-server. Here is one of the earlier issue for reference: https://github.com/dolthub/dolt/issues/3711

jycor avatar Jul 21 '22 17:07 jycor

I'm not sure about points 2 and 3, as defaulting to reading/writing to one of the directories could resulting in different behavior depending on where you run dolt sql or dolt sql-server.

The problem is for a new user, you get this random error and you don't understand what that directory is for. You look at it and it's empty and you're like WTF.

timsehn avatar Jul 21 '22 17:07 timsehn

Options 1 and 2 seem like they'll only delay the conflict – customers will still hit them, but it'll likely take them longer to hit them since they have to create some data for them. It could still help for the initial user experience or if someone accidentally starts the server in the wrong dir though.

Having a defined order of precedence seems pretty intuitive.

fulghum avatar Jul 21 '22 17:07 fulghum

Options 1 and 2 seem like they'll only delay the conflict – customers will still hit them, but it'll likely take them longer to hit them since they have to create some data for them. It could still help for the initial user experience or if someone accidentally starts the server in the wrong dir though.

I think this is primarily a new user issue. Once things are in there, like permissions, it starts to make more sense.

timsehn avatar Jul 21 '22 17:07 timsehn

Yup, I agree. Option 1 seems like a nice, simple optimization that we probably want to have anyway and it'll help with this sharp edge for the new user experience. Option 2 feels a little more hacky to me, and Option 3 adds more complexity that hopefully we can avoid longer and not rush into.

fulghum avatar Jul 21 '22 17:07 fulghum

OK @JCOR11599. Just make this directory when we actually need to write a file in it. I think that delays the issue long enough for a user to experience enough of Dolt to have more context to understand the error.

timsehn avatar Jul 21 '22 17:07 timsehn

This is fixed. We went with option (1).

timsehn avatar Aug 12 '22 00:08 timsehn