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,formadded
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
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)
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
npxandbunx --bunand create a new project withshadcnandformset for--add-ons. The only minor thing remaining is that in Powershell theInstalling 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 🙏🏼
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 😄 )
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:
npxis not found and the v0.9.4 code was hard-coded to usenpxregardless of whether the initial command wasbunxordenoor 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-L46shadcn@latestis not honoring--yesor--silentand/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.
I’ll check the paths on the add-ons flags. That’s going to solve an issue that some folks have seen that
shadcn formis not an add-on. But it won’t solve the hanging issue on installing theshadcncomponents. That looks to be an issue on the shadcn CLI side.It doesn’t look like
shadcn-uisupports bypassing this prompt via any of its CLI flags (such as--silentor--yesas you’ve tried already @jherr ) (code here).(As it looks like you figured out in 0.9.3, the
--forcementioned in the warning fromshadcn-uirefers to a flag that it can use when it is installing the dependencies needed for the components you’ve asked it to add, e.gnpm install foo@bar --force, to get around the possiblepeerDependenciesissue present with React 19. It’s not a flag toshadcn-ui’s CLI itself).It feels like the “proper” solution here is for
shadcn-uito either respect--yeswith 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
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:npmyarnpnpmbundenoFor making sure the correct manager is being used, I added the below inside of
environment.jswhere it’s located in the npx cacheAll of the package managers were used properly after the update at https://github.com/TanStack/create-tsrouter-app/commit/23fd4bbe54a3a9b44976076dad6baa1c2ac199f0
BINGO!!!
with
execaSyncI can capture the event, howeverexecadoesn’t recognize fully thenpxcommand and looks for gibberish conditionals.However, I can’t select any option. It seems
execadoesn’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
environment.executeis just a wrapper aroundexeca. We wrap it so that, in this case, we can run non-destructive tests. Theenvironmentstuff is actually critical for a new feature that will allow us to add add-ons to an existing project.I’ve noticed that when using the shadcn CLI directly, it doesn’t seem to respect the
--yesflag.Another thing I’ve noticed is that it works when running it in a debugger, but not in the current release lol
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.