unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.8k stars 271 forks source link

Aborting project creation puts the UCM session into a weird state where the project exists but can't be deleted #5309

Open puffnfresh opened 2 months ago

puffnfresh commented 2 months ago

Describe and demonstrate the bug

From a new install of Unison:

scratch/main> project.create optics

  🎉 I've created the project optics.

  I'll now fetch the latest version of the base Unison library...

Aborted.
scratch/main> projects

  1. optics
  2. scratch

scratch/main> project.delete optics
Encountered exception:
SqliteQueryException {sql = "DELETE FROM project_branch WHERE project_id = ?", params = [SQLText "a75875b2-5d8a-4131-8903-b70164b3d7b9"], exception = SQLite3 returned ErrorConstraint while attempting to perform step: FOREIGN KEY constraint failed, callStack = [("throwSqliteQueryException",SrcLoc {srcLocPackage = "unison-sqlite-0.0.0-7zRGXUqStVqHPpxGEGb6NZ", srcLocModule = "Unison.Sqlite.Connection", srcLocFile = "src/Unison/Sqlite/Connection.hs", srcLocStartLine = 158, srcLocStartCol = 5, srcLocEndLine = 158, srcLocEndCol = 30}),("execute",SrcLoc {srcLocPackage = "unison-sqlite-0.0.0-7zRGXUqStVqHPpxGEGb6NZ", srcLocModule = "Unison.Sqlite.Transaction", srcLocFile = "src/Unison/Sqlite/Transaction.hs", srcLocStartLine = 237, srcLocStartCol = 24, srcLocEndLine = 237, srcLocEndCol = 42}),("execute",SrcLoc {srcLocPackage = "unison-codebase-sqlite-0.0.0-7lCUtYpFiYi5uCTllMGTTh", srcLocModule = "U.Codebase.Sqlite.Queries", srcLocFile = "./U/Codebase/Sqlite/Queries.hs", srcLocStartLine = 3883, srcLocStartCol = 3, srcLocEndLine = 3883, srcLocEndCol = 10})], connection = Connection { name = "main", file = "/home/nixos/.unison/v2/unison.sqlite3" }, threadId = ThreadId 719}
scratch/main> exit

When loading Unison back up, we can see that we're actually already on the optics project, and it can easily be deleted:

$ ucm
optics/main> project.delete optics
scratch/main>

Screenshots

Environment (please complete the following information):

aryairani commented 1 month ago

I just ran into this as well. Thanks for the workaround.