# Multiple Error: Attempting to index a nil value

**URL:** <https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307>\
**Category:** Troubleshooting\
**Created:** [September 30, 2025, 10:00pm UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307 "2025-09-30T22:00:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@Matt](https://community.silverbullet.md/u/Matt)\
**Post date:** [September 30, 2025, 10:00pm UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/1 "2025-09-30T22:00:00Z")

</div>

Hi All!

I’m suddenly getting this error below based on the further below space-lua config. I hadn’t changed anything recently to cause the issue (that I remember!). I’m getting at least 10-15 similar errors when the client loads.

Any thoughts on what’s going on?

[Client] Statement errored out during boot, but ignoring: command.define {  
name = “Custom: Toggle Task”,  
description = “Toggle between task or not”,  
key = “Ctrl-Shift-t”,  
run = customToggleTask  
} Error: Attempting to index a nil value

```space-lua
function customToggleTask()
  local line = editor.getCurrentLine()  
  local text = line.text  
    
  if string.startsWith(text, "- [] ") then  
    -- Remove the task prefix  
    editor.replaceRange(line.from, line.from + 6, "")  
  else  
    -- Add the task prefix  
    editor.insertAtPos("- [] ", line.from)  
  end  
end

command.define {  
  name = "Custom: Toggle Task",
  description = "Toggle between task or not",  
  key = "Ctrl-Shift-t",    
  run = customToggleTask
}

slashcommand.define {
  name = "Custom: Toggle Task",
  description = "Toggle between task or not",  
  run = customToggleTask
}

```

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [October 1, 2025, 10:41am UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/2 "2025-10-01T10:41:14Z")

</div>

Ok I understand this is confusing, but it should be harmless, you can ignore these errors. I’m guessing you’re defining some custom commands in your CONFIG page?

Some background on what’s happening here: to support certain new configuration options (specifically around indexing and sync) I now have to load your CONFIG file when the client boots, way before the whole editor is ready. The way I do this is by running the Lua code in the CONFIG page with some very limited set of APIs exposed (mostly only the config.\* ones). Everything else is not yet available and will therefore fail “quietly” (the “but ignoring” is the quiet part). Later on, the full config is loaded properly and these errors shouldn’t reappear.

What of course is confusing here is that you still see those errors, so perhaps I’ll just hide them completely or mark them even more explicilty “THIS FAILED BUT IT’S OK!!!11” 😉 I’ll think if I’ll just mute errors entirely for a future release.

If you don’t like these errors, or perhaps even as a better practice: what you can do is simply move anything that’s not `config.*` calls from your CONFIG page to a separate page, e.g. `Library/Commands`, or call it whatever you like the name doesn’t matter. That should solve the issue (and may be cleaner anyway).

---

<div class="post-metadata">

**Author:** ![mjf](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mjf/32/654_2.png) [@mjf](https://community.silverbullet.md/u/mjf)\
**Post date:** [October 1, 2025, 12:10pm UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/3 "2025-10-01T12:10:19Z")

</div>

> [@zef](#):
>
> I’ll think if I’ll just mute errors entirely for a future release

Please, don’t! 🙄

> what you can do is simply move anything that’s not config.\* calls from your CONFIG page to a separate page, e.g. Library/Commands, or call it whatever you like the name doesn’t matter. That should solve the issue (and may be cleaner anyway).

This! 👏

* * *

We should maintain some BCP in docs to avoid common flaws, by the way…

---

<div class="post-metadata">

**Author:** ![MrMugame](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mrmugame/32/358_2.png) [@MrMugame](https://community.silverbullet.md/u/MrMugame)\
**Post date:** [October 1, 2025, 12:16pm UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/4 "2025-10-01T12:16:04Z")

</div>

> Please, don’t! 🙄

I think he meant just for this pre loading stage

---

<div class="post-metadata">

**Author:** ![mjf](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mjf/32/654_2.png) [@mjf](https://community.silverbullet.md/u/mjf)\
**Post date:** [October 1, 2025, 12:40pm UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/5 "2025-10-01T12:40:31Z")

</div>

> [@MrMugame](#):
>
> I think he meant just for this pre loading stage

Ah, OK. I misred it. 😉

Well, I think this, and perhaps few other things, could be solved if we indexed the Space Lua and Space Style scripts, including page and tags. Together with the `priority` comments it seems like as powerful to avoid most loading and syncing quirks. (Just an idea, again.)

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [October 1, 2025, 2:50pm UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/6 "2025-10-01T14:50:57Z")

</div>

All that is indexed, and this is also how space lua is generally loaded (straight from the index). However the case I had to cover is the initial sync case: fresh browser, nothing there. How do I now know what files I need to sync if there’s configuration options that can change this buried all over your space? Same for indexing, how do you configure the indexer if it hasn’t indexed the configuration options yet 😉 Bootstrapping problems.

In the end the best I could come up with is to assume these options all appear in CONFIG and preload them from there. Not super excited about this solution, but don’t see a better solution that doesn’t involve going back to a server-side indexing model again.

---

<div class="post-metadata">

**Author:** ![Matt](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@Matt](https://community.silverbullet.md/u/Matt)\
**Post date:** [October 1, 2025, 5:59pm UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/7 "2025-10-01T17:59:57Z")

</div>

Ah, thanks for the detailed explanation. I was debugging something else and ran down the rabbit hole of these harmless errors (I had found out the commands still worked even though the console errors).

For me, debugging Lua in SB is relatively hard, only having the character number to start the search. These additional console messages do clutter/confuse up the logs. Hiding them on first parse/load/bootstrap process does make sense. ([Client] Error evaluating script: Attempting to index a nil value at [[CONFIG@1130]], um ok… where/what is that?!, opens up the file in vim, `:1130goto`)

Perhaps though this is part of a larger anti-pattern. If only config should be in [CONFIG.md](http://CONFIG.md), then a gentle user nudge could steer in that direction, ie "[CONFIG.md](http://CONFIG.md) is for configuring SilverBullet. For user commands, keyboard shortcuts, and functions, we suggest you put these in `Library/Commands`, `Library/Keyboard`, etc for organizational purposes.

Steering isn’t quite a _silverbullet_ for these cases though 😄

---

<div class="post-metadata">

**Author:** ![mjf](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mjf/32/654_2.png) [@mjf](https://community.silverbullet.md/u/mjf)\
**Post date:** [October 2, 2025, 3:08am UTC](https://community.silverbullet.md/t/multiple-error-attempting-to-index-a-nil-value/3307/8 "2025-10-02T03:08:28Z")

</div>

> [@zef](#):
>
> Bootstrapping problems.
> 
> In the end the best I could come up with is to assume these options all appear in CONFIG and preload them from there. Not super excited about this solution, but don’t see a better solution that doesn’t involve going back to a server-side indexing model again.

Now I see…
