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

Fix handling of absolute config files in upgrade tool #15927

Merged
merged 3 commits into from
Jan 28, 2025

Conversation

philipp-spiess
Copy link
Member

@philipp-spiess philipp-spiess commented Jan 27, 2025

Closes #15220

This PR fixes an issue where the upgrade tool would not be able to load some JavaScript config files across different drive letters on Windows.

The issue in detail is that path.relative(…) tries to build a relative path but if the file is inside the same folder, it won't start the relative path with a ./ so we manually appended it in case that it isn't there. The issue on Windows specifically is that file.relative(…) can also return a legit absolute path, e.g. when the file is on a different drive. In this case we obviously don't want to prefix a path with ./.

Test plan

To reproduce this issue, I checked out a Tailwind v3 project on a different drive letter than my Windows installation. In that case, I was adding a repo inside D: while npm was installed in C:. I then run npx @tailwindcss/upgrade to reproduce the issue.

The fix was validated with a local bun run of the upgrade tool:

telegram-cloud-photo-size-4-5818901845756725194-y

@philipp-spiess philipp-spiess requested a review from a team as a code owner January 27, 2025 14:29
Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a simple fix, love it!

@philipp-spiess philipp-spiess merged commit 2c1dea4 into next Jan 28, 2025
5 checks passed
@philipp-spiess philipp-spiess deleted the fix/win-upgrade-absolute-files branch January 28, 2025 11:42
@kudziajaroslaw98
Copy link

Problem still persist.
I removed npx cache, removed package, npm upgrade, installed it and ran again.

≈ tailwindcss v4.0.0                                                                                                                                                                                                                                                                                                                                    

│ Searching for CSS files in the current directory and its subdirectories… 

│ ↳ Linked `.\tailwind.config.ts` to `.\src\app\globals.css` 

│ Migrating JavaScript configuration files…

│ ↳ Could not load the configuration file: Can't resolve '././D:\<HappyPath>\tailwind.config.ts' in 'C:\<EvenHappierPath>\npm-cache\_npx\001fd1a00a7ecb8d\node_modules\@tailwindcss\upgrade\dist' 

@msoler75
Copy link

Same problem here:

PS D:\projects\tseyor\laravel_inertia> npm cache clean --force
npm warn using --force Recommended protections disabled.
PS D:\projects\tseyor\laravel_inertia> 
PS D:\projects\tseyor\laravel_inertia> npx @tailwindcss/upgrade@next
≈ tailwindcss v4.0.0

│ Searching for CSS files in the current directory and its subdirectories… 

│ Migrating JavaScript configuration files… 

│ ↳ Could not load the configuration file: Can't resolve 
│   '././D:\projects\tseyor\laravel_inertia\tailwind.config.js' in
│   'C:\Users\Marcel\AppData\Local\npm-cache\_npx\0044b4041b3b52e1\node_modules\@tailwindcss\upgrade\dist'

PS D:\projects\tseyor\laravel_inertia> 

@philipp-spiess
Copy link
Member Author

@kudziajaroslaw98 @msoler75 hey! Sorry for the confusion but we only release v4.0.1 right now. Mind updating and trying again?

@thecrypticace
Copy link
Contributor

It's not quite out yet — waiting for the build to finish and npm to publish it. Should be like… 10–15m from now.

@thecrypticace
Copy link
Contributor

It's out now 👍

@dimitrov93
Copy link

i got the same issue, any fix? :(

@kudziajaroslaw98
Copy link

kudziajaroslaw98 commented Jan 30, 2025

I don't know if it's me but it's not working still.
The problem changed tho.

≈ tailwindcss v4.0.1

│ Searching for CSS files in the current directory and its subdirectories…

│ ↳ Linked `.\tailwind.config.ts` to `.\src\app\globals.css`

│ Migrating JavaScript configuration files…

│ ↳ Could not load the configuration file: e is not a function

@marcopedone
Copy link

Same problem here

≈ tailwindcss v4.0.1

│ Searching for CSS files in the current directory and its subdirectories…

│ ↳ Linked `.\tailwind.config.ts` to `.\src\styles\globals.css`

│ Migrating JavaScript configuration files…

│ ↳ Could not load the configuration file: v is not a function

@philipp-spiess
Copy link
Member Author

@marcopedone @kudziajaroslaw98 This seems to be a different error, mind creating a new issue with a repro so we can take a look?

@al-imam
Copy link

al-imam commented Jan 31, 2025

Issues is not resolved but pull request it closed 😂
Merged without proper testing.

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

Successfully merging this pull request may close these issues.

Upgrade tool can't resolve paths on Windows
8 participants