create-tsrouter-app: CLI stuck in loop with both `shadcn` and `form` in add-ons

Which project does this relate to?

Create Tanstack App

Describe the bug

When creating a new project with both shadcn and form in add-ons, the CLI gets stuck in a loop when it gets to adding the shadcn-ui components. I ran the install with bunx --bun but it also happens with npx, with or without the --package-manager flag or --toolchain. The shadcn-ui install process works fine standalone, it’s only when form is also added that it gets stuck.

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

  • Open terminal
  • Run install command with --add-ons shadcn,form added

Expected behavior

I was able to run the same command just fine yesterday but saw today’s update about Tanstack Form setup with shadcn-ui so I wanted to try that out.

Screenshots or Videos

Image Image

https://github.com/user-attachments/assets/9dc6ea35-cdcc-47db-bd54-567f1e5f51fe

Platform

  • OS: Windows 10
  • Terminal: Windows Terminal with Powershell
  • Version: 0.9.0

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 54 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Our PR got merged last night!

Big win for the whole community. It’s good for shadcn as well!

Happy to report that the issue is (essentially) fixed 🎉 I was able to run the command with npx and bunx --bun and create a new project with shadcn and form set for --add-ons. The only minor thing remaining is that in Powershell the Installing shadcn components.. line does still print repeatedly but ultimately, the install/setup goes through so not a huge issue (at least for me, personally). Definitely wasn’t the case before though, I did leave the install process to run for some time and it never completed. This is still Powershell only though - in a normal Command Prompt everything went as expected with no repeated prints.

https://github.com/user-attachments/assets/2fa3c6f2-99b0-41b4-8876-eba5fcef2d5f

Once again, thanks to everyone who contributed and helped out. Big shout out to @jherr and @ErickRodrCodes especially, thanks so much 🙏🏼

So, I’m seeing the logs passing when using spinner… Apparently we are hitting a block when using React 19… unfortunately we cannot interact wit the wizard when that happens… Image the terminal dies because we can’t pass --force or --legacy-peer-deps Image So I think the ball now is on Shadcn court, as we can’t fix the peer dependencies if we use React 19

Here is our pull request: shadcn-ui/ui#6965 Let me know if you think I need to alter it.

A total pleasure, so far this is my first contribution in a field I’m not an expert lol (I’m more Angular/Nx folk 😄 )

So, I’m seeing the logs passing when using spinner… Apparently we are hitting a block when using React 19… unfortunately we cannot interact wit the wizard when that happens…

Image

the terminal dies because we can’t pass --force or --legacy-peer-deps

Image

So I think the ball now is on Shadcn court, as we can’t fix the peer dependencies if we use React 19

Here is our pull request: https://github.com/shadcn-ui/ui/pull/6965 Let me know if you think I need to alter it.

Ok, I think there are two primary issues here:

  1. Sometimes npx is not found and the v0.9.4 code was hard-coded to use npx regardless of whether the initial command was bunx or deno or whatever. So now v0.9.5 will run the appropriate download and execute (dlx) based on that your package manager is set to. https://github.com/TanStack/create-tsrouter-app/blob/main/src/package-manager.ts#L27-L46
  2. shadcn@latest is not honoring --yes or --silent and/or is being inconsistent about when it’s reporting issues with React 19. I’ve reached out to shadcn. And if I don’t hear anything back I’ll dig in there. I did some work on their CLI a while back.

If you are still interested in this issue. Please help me debug through any issues with #1 here to make sure that for each of the package managers we are running the correct command.

seeing that npx create-tsrouter-app --add-ons shadcn,form hangs because it is really not setting a set per each part of the argument: Image so, it seems the problem is that the previous callee doesn’t normalize the options to be an array, rather it passes a string instead.

@jherr 👀

I’ll check the paths on the add-ons flags. That’s going to solve an issue that some folks have seen that shadcn form is not an add-on. But it won’t solve the hanging issue on installing the shadcn components. That looks to be an issue on the shadcn CLI side.

It doesn’t look like shadcn-ui supports bypassing this prompt via any of its CLI flags (such as --silent or --yes as you’ve tried already @jherr ) (code here).

(As it looks like you figured out in 0.9.3, the --force mentioned in the warning from shadcn-ui refers to a flag that it can use when it is installing the dependencies needed for the components you’ve asked it to add, e.g npm install foo@bar --force, to get around the possible peerDependencies issue present with React 19. It’s not a flag to shadcn-ui’s CLI itself).

It feels like the “proper” solution here is for shadcn-ui to either respect --yes with regards to this prompt and auto-select an option, or to provide an additional CLI parameter to specify an option in lieu of the prompt.

Yes, and Shadcn are using execa too, then the user will touch execa if install Shadcn for example. Make no sense to change, you are right.

Here’s what I got in my testing with v0.9.5

Package Manager Status Notes
npm ❌ hangs on shadcn add
yarn ✅
pnpm ✅
bun ❌ hangs on shadcn add
deno 🟨 finishes, but shadcn add fails

Command template:

npx create-tsrouter-app@latest __TEST_PROJ__ --template file-router --tailwind --add-ons "shadcn,form" --package-manager <package manager>

where <package manager> is one of:

  • npm
  • yarn
  • pnpm
  • bun
  • deno

For making sure the correct manager is being used, I added the below inside of environment.js where it’s located in the npx cache

execute: async (command, args, cwd) => {
    try {
        console.log('cwd', cwd);
        console.log(`Executing "${command} ${args.join(' ')}"`);
        const res = await execa(command, args, {
            cwd,
            stdout: 'inherit',
            stderr: 'inherit',
        });
        console.log(res.stderr);
        console.log(res.stdout);
    }
    catch {
        errors.push(`Command "${command} ${args.join(' ')}" did not run successfully. Please run this manually in your project.`);
    }
},

All of the package managers were used properly after the update at https://github.com/TanStack/create-tsrouter-app/commit/23fd4bbe54a3a9b44976076dad6baa1c2ac199f0

BINGO!!!

Image

with execaSync I can capture the event, however execa doesn’t recognize fully the npx command and looks for gibberish conditionals.

However, I can’t select any option. It seems execa doesn’t forwards other wizards.

Let me create a dummy project using execs and npx something in my windows machine. I’m suspecting execa has a bug if used along with npx

let me check execSync which should be the right way to run things… environment.execute is not the best call here…

environment.execute is just a wrapper around execa. We wrap it so that, in this case, we can run non-destructive tests. The environment stuff is actually critical for a new feature that will allow us to add add-ons to an existing project.

Image

I’ve noticed that when using the shadcn CLI directly, it doesn’t seem to respect the --yes flag.


Another thing I’ve noticed is that it works when running it in a debugger, but not in the current release lol

Image

I’m using PowerShell 7.5.0 for what it’s worth. I know it’s cross platform, so I’ll try it under WSL and report back to see if it’s a shell thing, windows thing, shadcn thing, or some combination.


This is an enigma because both bash and pwsh are hanging on the shadcn stuff in WSL lol. It looks like @ErickRodrCodes is getting completely different results than me too, which doesn’t really help this issue lol.

I don’t have Windows or Powershell. Please help me by digging into the code and providing some additional diagnostics.