Skip to content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Resolves: #19948

Description

This linked issue indicates a problem when using unattended installs with a SQLite database for a newly cloned repository. The /umbraco/Data directory doesn't exist which leads to an exception being thrown.

I couldn't actually replicate this. In my tests I would always find a MainDom_*.lock file written into /umbraco/Data/Temp, so by the time the SQLite database was being created in the unattended install, the directory was already there.

Nonetheless it's fairly easy to see what the fix would be if it wasn't - and if using storage in another location ensuring the directory exists would still be useful. So I've applied it here - a check to see if the directory where the SQLite database is going to be copied to exists, and if it doesn't, create it.

Testing

To test I found I needed to use a non-default location, so configure the something like the following for the database connection string:

  "ConnectionStrings": {
    "umbracoDbDSN": "Data Source=c://temp//test//UmbracoUnattended.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True",
    "umbracoDbDSN_ProviderName": "Microsoft.Data.Sqlite"
  }

And the following for unattended install:

  "Unattended": {
    "InstallUnattended": true,
    "UnattendedUserName": "{user name}",
    "UnattendedUserEmail": "{email}",
    "UnattendedUserPassword": "{password}",
  },

Start up Umbraco. You should find that before these changes an exception would be thrown due to the directory not existing:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\temp\test\UmbracoUnattended.sqlite.db'.

But with these changes in place it'll create it and start up normally.

Copilot AI review requested due to automatic review settings August 25, 2025 06:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

@kjac kjac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm 👍

@kjac kjac merged commit da7454e into main Aug 26, 2025
26 checks passed
@kjac kjac deleted the v16/improvement/ensure-directory-exists-when-creating-sqlite-db branch August 26, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't install if /umbraco/Data is missing

3 participants