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

Packages fail to install #65

Closed
nexxeln opened this issue Jun 28, 2022 · 16 comments · Fixed by #67
Closed

Packages fail to install #65

nexxeln opened this issue Jun 28, 2022 · 16 comments · Fixed by #67
Labels

Comments

@nexxeln
Copy link
Member

nexxeln commented Jun 28, 2022

Describe the bug
After selecting packages to install it fails and shows this error

Aborting installation...
Error: ENOENT: no such file or directory, lstat 'template/base'

To Reproduce
Steps to reproduce the behavior:

  1. npx create-t3-app@latest
  2. Select any packages
  3. See the error

Expected behavior
Packages should be installed

Screenshots
ss

@klipitkas
Copy link

Can confirm, does the same for me.

@juliusmarminge
Copy link
Member

juliusmarminge commented Jun 28, 2022

is the constant PKG_ROOT accurate? it seems to be failing to copy over the base app when it scaffolds the project. not when it is installing the packages

EDIT: latest version on main branch (4.2.8) seems to work for me:
pnpm: https://app.warp.dev/block/75es65LAphP8aXQLUqrJZc
npm: https://app.warp.dev/block/KzdwQSg7VHIIMN7EvRsiPo

@nexxeln
Copy link
Member Author

nexxeln commented Jun 28, 2022

Thats interesting, works for you but not for me

@juliusmarminge
Copy link
Member

juliusmarminge commented Jun 28, 2022

I also have no issues running the CLI directly from npm store: https://app.warp.dev/block/H3HrXKP4E2yQtnfzflNLzd

EDIT: nvm running it when I'm not in the package directory fails: https://app.warp.dev/block/TapKvjoErC2CPtQlGHHhSV. even more reason to think the PKG_ROOT path is inaccurate

@devkevbot
Copy link
Contributor

One very hacky solution: (seems to work for me, needs more testing)

import path from "path";
import { fileURLToPath } from "url";
import { dirname } from "path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// With the move to TSUP as a build tool, this keeps path routes in other files (installers, loaders, etc) in check more easily.
// Path is in relation to a single index.js file inside ./dist
export const PKG_ROOT = path.join(__dirname, "../");

@juliusmarminge
Copy link
Member

how are you getting the error when running the build locally?

@devkevbot
Copy link
Contributor

I also have no issues running the CLI directly from npm store: https://app.warp.dev/block/H3HrXKP4E2yQtnfzflNLzd

EDIT: nvm running it when I'm not in the package directory fails: https://app.warp.dev/block/TapKvjoErC2CPtQlGHHhSV. even more reason to think the PKG_ROOT path is inaccurate

Yes, the PKG_ROOT seems to be pointing at the place where someone is executing the npx command, not the actual package directory

@juliusmarminge
Copy link
Member

should the template folder not ship with the CLI so that you don't have to do this hack and keep the paths as before?

@devkevbot
Copy link
Contributor

should the template folder not ship with the CLI so that you don't have to do this hack and keep the paths as before?

Well, I don't really see how we can avoid shipping the template folder since those files need to be copied during scaffold and install.

@devkevbot
Copy link
Contributor

how are you getting the error when running the build locally?

If you want to try to reproduce the error locally, you can install the package globally on your local machine and the try running npx create-t3-app, which should pick up that local install.

@juliusmarminge
Copy link
Member

i don't have much knowledge about how shipping packages works, but in the dist folder, the template is not included, so I assume when running npx create-t3-app it doesn't have access to the template folder since it is not built?

@devkevbot
Copy link
Contributor

i don't have much knowledge about how shipping packages works, but in the dist folder, the template is not included, so I assume when running npx create-t3-app it doesn't have access to the template folder since it is not built?

I'm not too experienced either, but here's the npm reference for which files get included: https://docs.npmjs.com/cli/v8/commands/npm-publish#files-included-in-package

@devkevbot
Copy link
Contributor

devkevbot commented Jun 28, 2022

Here's a summary of the problem as I understand it:

// The directory you are running npx create-t3-app in:
some/dir/

// The directory pointed to by the current version of PKG_ROOT:
some/

// The directory that the scaffolding step will look for:
some/template/base

Instead, we want the PKG_ROOT to point at the dirname of the package itself.

@juliusmarminge
Copy link
Member

juliusmarminge commented Jun 28, 2022

I believe that Kevins solution is good enough, and I can't seem to find any other way to get the path of the package itself.

Got a PR ready if you want me to submit it since Kevin logged off.

Have tested it and it seems reliable

@ghost
Copy link

ghost commented Jun 28, 2022

If you need confirmation of this being an issue, I just tried to use it and had the same issue as @nexxeln

@nexxeln
Copy link
Member Author

nexxeln commented Jun 28, 2022

If you need confirmation of this being an issue, I just tried to use it and had the same issue as @nexxeln

Thank you for confirming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants