darktable-org / darktable-org/darktable

bundled lua script don't load reliably with empty config

Open
#22,204 4 comments 0 reactions 1 assignee View on GitHub

@wpferguson is already working on this.

Since Sep 9, 2026.

reproduce: peculiar
Dominant language
C
Stars
13.1k
Forks
1.4k
Avg merge
22h 14m
Merged PRs (30d)
198

Description

Is there an existing issue for this?
  • I checked and did not find my issue in the already reported ones
Describe the bug

On an empty config directory, bundled Lua scripts sometimes fail to load. The issue is not reproducible every run. But when this issue is encountered lua scripts will not load in subsequent runs. Encountered using the AppImage.

Analysis with claude.ai

The intermittent behaviour of the issue suggests a race condition?

In tools/script_manager.lua, whether bundled scripts (<data_dir>/lua-scripts) or only <configdir>/lua get scanned depends on:

if string.match(scripts_path, ds.sanitize_lua(dt.configuration.data_dir)) then
  system_based = true
end

If false, <configdir>/lua (nonexistent on fresh config) is scanned instead → 0 scripts → folder_selector combobox built with selected = 1 but 0 entries → the error above.

data/luarc already has a fixed dt.control.sleep(1000) workaround for a related empty-config race (#21035) on first run. The flakiness suggests 1s isn't always enough to guarantee data_dir/package.path are ready when system_based is checked — same race class, not fully closed.

Suggested direction by claude.ai

Tie the require "tools/script_manager" call to the existing view-changed "none→lighttable" ready event already used in luarc, instead of a fixed sleep.

@wpferguson if you think the suggested fix makes sense I can open a PR - but I understand to little of the details to confidently open one now.

Steps to reproduce

Start any of the above with --configdir pointing to a new empty directory and -d lua;
repeat several times from the same shell with a freshly emptied config each time.
Result varies run to run. At least for me.

Expected behavior

No response

Logfile | Screenshot | Screencast
find: '<configdir>/lua': No such file or directory
... LUA INFO: callback: finished processing scripts
... LUA ERROR : Invalid index for combo box : 1

The line LUA lua dir is <data_dir>/lua-scripts is notably absent on failing runs.

Commit

No response

Where did you obtain darktable from?

darktable.org / GitHub release

darktable version

5.6.0, 5.6.1, current nightly (all AppImage).

What OS are you using?

Linux

What is the version of your OS?

bazzite 44

Describe your system

No response

Are you using OpenCL GPU in darktable?

None

If yes, what is the GPU card and driver?

No response

Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.