Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(include mod) depends on CWD / fennel.path value #128

Open
rktjmp opened this issue Jan 6, 2024 · 1 comment
Open

(include mod) depends on CWD / fennel.path value #128

rktjmp opened this issue Jan 6, 2024 · 1 comment

Comments

@rktjmp
Copy link
Owner

rktjmp commented Jan 6, 2024

Hm..

test/macros.fnl does use include and builds without issues.

Using elsewhere seem fails to find the module.

  • Does fennel.include hit the regular infra or use its own file searcher?
@rktjmp
Copy link
Owner Author

rktjmp commented Jan 6, 2024

Seems it uses specials.search-module

(fn search-module [modulename ?pathstring]
  (let [pathsepesc (escapepat pkg-config.pathsep)
        pattern (: "([^%s]*)%s" :format pathsepesc pathsepesc)
        no-dot-module (modulename:gsub "%." pkg-config.dirsep)
        fullpath (.. (or ?pathstring utils.fennel-module.path)
                     pkg-config.pathsep)]
    (fn try-path [path]
      (let [filename (path:gsub (escapepat pkg-config.pathmark) no-dot-module)
            filename2 (path:gsub (escapepat pkg-config.pathmark) modulename)]
        (match (or (io.open filename) (io.open filename2))
          file (do
                 (file:close)
                 filename)
          _ (values nil (.. "no file '" filename "'")))))

Which uses utils.fennel-module.path, require("fennel").path == ./?.fnl;./?/init.fnl`

Testing include b from fnl/ does work, so its a fennel.path issue.

  • patch fennel.path to match package.path (really needs to match vim "rtp", package.path will not be sufficent) OR
  • ... cwd to match fnl/ when compiling? Probably not OR
  • patch fennel?

@rktjmp rktjmp changed the title (include mod) not functional? (include mod) depends on CWD / fennel.path value Jan 6, 2024
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

No branches or pull requests

1 participant