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

Following default setup instructions leads to error starting process #32

Open
bklein18 opened this issue May 1, 2024 · 3 comments
Open

Comments

@bklein18
Copy link
Collaborator

bklein18 commented May 1, 2024

Hello, apologies if this has been asked before. I tried integrating SwiftyTailwind with an existing Vapor project, and despite SwiftyTailwind correctly finding the binary, I'm getting the following error when I try to actually run the Vapor project.

[ INFO ] Tailwind: /var/folders/cl/pm3kms754_zg_17w7d8_9d_r0000gq/T/SwiftyTailwind/v3.4.3/tailwindcss-macos-arm64 init
[ WARNING ] posix_spawn error: Permission denied (13), `["/var/folders/cl/pm3kms754_zg_17w7d8_9d_r0000gq/T/SwiftyTailwind/v3.4.3/tailwindcss-macos-arm64", "init"]`
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: posix_spawn error: Permission denied (13), `["/var/folders/cl/pm3kms754_zg_17w7d8_9d_r0000gq/T/SwiftyTailwind/v3.4.3/tailwindcss-macos-arm64", "init"]`

I then attempted running chmod +x tailwindcss-macos-arm64 in the Package directory (even though this seemed like it should be handled by the package code) and got the following, slightly different error.

[ INFO ] Tailwind: /var/folders/cl/pm3kms754_zg_17w7d8_9d_r0000gq/T/SwiftyTailwind/v3.4.3/tailwindcss-macos-arm64 init
[ WARNING ] posix_spawn error: Malformed Mach-o file (88), `["/var/folders/cl/pm3kms754_zg_17w7d8_9d_r0000gq/T/SwiftyTailwind/v3.4.3/tailwindcss-macos-arm64", "init"]`
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: posix_spawn error: Malformed Mach-o file (88), `["/var/folders/cl/pm3kms754_zg_17w7d8_9d_r0000gq/T/SwiftyTailwind/v3.4.3/tailwindcss-macos-arm64", "init"]`

Potentially relevant info below:

My file structure
Screenshot 2024-04-30 at 22 14 53

Tailwind configuration:

import Leaf
import SwiftyTailwind
import TSCBasic
import Vapor

func tailwind(_ app: Application) async throws {
    let resourecesDirectory = try AbsolutePath(validating: app.directory.resourcesDirectory)
    let publicDirectory = try AbsolutePath(validating: app.directory.publicDirectory)

    let tailwind = SwiftyTailwind()
    try await tailwind.initialize()
    try await tailwind.run(
        input: .init(validating: "Styles/app.css", relativeTo: resourecesDirectory),
        output: .init(validating: "styles/app.generated.css", relativeTo: publicDirectory),
        options: .content("\(app.directory.viewsDirectory)**/*.leaf")
    )
}

// configures your application
public func configure(_ app: Application) async throws {
    app.views.use(.leaf)
    
    try await tailwind(app)
    app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
    
    try routes(app)
}

This seems like there is something potentially wrong with the library code, but it's hard for me to tell for sure as I'm not only new to Tailwind, but also to Vapor. Please let me know if any more information is necessary or if there is a step I missed. Thank you!

@jagreenwood
Copy link
Contributor

Hello @bklein18! I ran in to this as well. What I found was that the tailwind binary was only partially downloaded (7.2MB for me vs 42MB). Deleting the cached binary to force a re-d/l resolved the condition for me.

Question is why did the binary only partially download? idk, but I would expect this package to handle that failure state better, so that is probably a bug.

@bklein18
Copy link
Collaborator Author

bklein18 commented May 1, 2024

@jagreenwood thanks for the advice! I tried what you said and deleting the binary did work. Definitely weird that this didn't happen. Maybe there is an opportunity for a checksum or something else in order to make sure the downloaded tailwind binary is correct.

@pepicrft
Copy link
Collaborator

pepicrft commented May 2, 2024

I'm onboard with the idea of having checksum validation. The experience of having to delete the binary manually is far from ideal. Feel free to go ahead and submit a PR. I'll be happy to review it.

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