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

EISDIR: illegal operation on a directory, read #147

Open
sadeghbarati opened this issue Mar 7, 2024 · 2 comments
Open

EISDIR: illegal operation on a directory, read #147

sadeghbarati opened this issue Mar 7, 2024 · 2 comments

Comments

@sadeghbarati
Copy link
Contributor

sadeghbarati commented Mar 7, 2024

Environment

Tested with node v18.8.2 on Windows
and node 20.11.1 in macOS
and node v18.8.0 in StackBlitz

@pi0 sorry for the tag, but we very much need this fix in shadcn-vue 🙏
related issue in shadcn-vue radix-vue/shadcn-vue#387

Reproduction

Describe the bug

Tested in

Windows 11 ❌
macOS ❌
StackBlitz ✅

Looks like c12 cannot resolve config when the name and config file are the same name as another directory like

components.json in the root
empty component directory (folder) in the root

Additional context

I think it's related to Jiti

Logs

Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:751:3)
    at tryReadSync (node:fs:451:20)
    at readFileSync (node:fs:497:19)
    at Object.jiti (***\Projects\Vue\c12-error\node_modules\.pnpm\j[email protected]\node_modules\jiti\dist\jiti.js:1:254411)
    at resolveConfig (file:///***/Projects/Vue/c12-error/node_modules/.pnpm/[email protected]/node_modules/c12/dist/index.mjs:330:26)
    at loadConfig (file:///***/Projects/Vue/c12-error/node_modules/.pnpm/[email protected]/node_modules/c12/dist/index.mjs:140:40)
    at getRawConfig (file:///***/Projects/Vue/c12-error/c12.js:27:34)
    at main (file:///***/Projects/Vue/c12-error/c12.js:43:24)
    at file:///***/Projects/Vue/c12-error/c12.js:48:1
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  errno: -4068,
  syscall: 'read',
  code: 'EISDIR'
}
@pi0
Copy link
Member

pi0 commented Mar 7, 2024

Thanks for detailed reproduction it helps a LOT. I will be back to it but probably not this week, if you had time to investigate down to jiti (hint: I guess it is esm resolve and mlly) that would accelerate fixing this issue.

BTW: As best practice, please consider explicitly naming your config after your tool (not generic names like components or app)

@dargmuesli
Copy link

It looks like at

return options.jiti!.resolve(id, { paths: [options.cwd!] });

jiti needs to be told to only try to resolve files, not directories, right?

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

3 participants