SwiftyTailwind
SwiftyTailwind copied to clipboard
Following default setup instructions leads to error starting process
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
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!
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.
@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.
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.