Confusing error messages when using Dolt CLI from within a running Dolt sql-server directory
fulghum opened this issue · comments
When running a Dolt sql-server from a directory that has not been dolt-init'ed yet, attempting to run dolt CLI commands from that non-init'ed directory results in confusing error messages that make it difficult for customers to understand what's wrong and what to do next.
The root of the problem is that dolt sql-server
creates a .dolt
directory (with a single sql-server.info
file), and when the CLI sees this directory exists, it assumes that it is a valid Dolt database directory that has been initialized.
After auditing, these are the commands that do not give good error messages today:
dolt ls
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt init
Failed to initialize directory as a data repo. .dolt directory already exists at '.'
dolt show main
error resolving spec ref 'main': open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt branch
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt checkout main
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt conflicts cat
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt cherry-pick main
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt pull
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt push
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt config --local --list
Unable to read config.
dolt remote
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt schema show
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt table export foo
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt tag
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt constraints verify
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt migrate
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt dump
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt gc
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt filter-branch
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt merge-base
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt docs print
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt stash
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt rebase
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
dolt query-diff
The current directories repository state is invalid
open /tmp/may17/.dolt/repo_state.json: no such file or directory
Many other dolt commands print a more helpful error message:
dolt reflog
The current directory is not a valid dolt repository.
We should fix the commands above so that they also print out "The current directory is not a valid dolt repository" instead of printing the current error about repository state.
For dolt init
, we should print a message about this being a running sql-server directory and tell the user to stop the sql-server and then run dolt init
if they want to initialize this directory, then they can restart dolt sql-server.
This likely comes from Dolt just looking for the existence of a .dolt directory to determine if a dolt directory has been initialized. Changing that check to look more deeply into the directory and look for the noms subdirectory would likely fix all the commands above to have a better error message, although we probably still want to special case dolt init
, since initializing a directory while a sql-server is running out of it will have weird behavior since the sql-server won't find the new dolt database until it's restarted.
Alternatively, we could consider changing dolt sql-server to store the sql-server.info file in .doltcfg instead of in the .dolt directory, but we'd need to allow the client to look in both locations for a while.
Related to #7873