We have base LUA file ~/.hammerspoon/init.lua which can load a spoon package:
hs.loadSpoon("Foo") Now we have our package file init.lua by path: ~/.hammerspoon/Spoons/Foo.Spoon/init.lua
It works fine.
I create a file my/bar.lua inside this package. Full path:
`~/.hammerspoon/Spoons/Foo.Spoon/my/bar.lua` with code:
return {} and it should be included in ~/.hammerspoon/Spoons/Foo.Spoon/init.lua:
local bar = require("Foo.Spoon.my.bar") We will see similar error:
Error loading Foo:..poon.app/Contents/Resources/extensions/hs/_coresetup.lua:662: module 'Foo.Spoon/my/bar' not found: no field package.preload['Foo.Spoon/my/bar'] no file '/Users/me/.hammerspoon/Foo/Spoon/my/bar.lua' no file '/Users/me/.hammerspoon/Foo/Spoon/my/bar/init.lua' no file /Users/me/.hammerspoon/Spoons/Foo/Spoon/my/bar.spoon/init.luat26: no file opt/homebrew/share/lua/5.4/Foo/Spoon/my/bar.lua' ... I played with various options like
require("my.bar")require("Foo.my.bar")
all of them fail.
Problem
In case of using require("Foo.Spoon.my.bar"), it looks like the loader the loader always replaces "." with "/" which breaks options to mention the package folder Foo.Spoon.
But it suppose to keep "Foo.Spoon" instead of "Foo/Spoon".
And it does not:
no file '/Users/me/.hammerspoon/Foo/Spoon/my/bar.lua' no file According to logs it obviously walks around, but does not look at the Foo.Spoon directory (tried .spoon it in lowercase too), which is strange.
Any advice/workaround (but without changing "require" function, or using absolute paths)?..
P.S. I took a look at related other posts.