jacobobryant / biff

A Clojure web framework for solo developers.
https://biffweb.com
MIT License
829 stars 40 forks source link

Error while executing task: css #166

Closed nate-sys closed 11 months ago

nate-sys commented 11 months ago

The issue

After following the getting started guide, the css suddenly stopped working. None of the pages were being styled and trying to run bb css manually errors with Error while executing task: css.

I tried to run it again after installing tailwindcss globally using npm and got this error:

up to date, audited 1 package in 159ms

found 0 vulnerabilities
clojure.lang.ExceptionInfo: Error while executing task: dev
{:proc {:proc #object[java.lang.ProcessImpl 0x4d8af460 "Process[pid=26438, exitValue=139]"], :exit 139, :in #object[java.lang.ProcessBuilder$NullOutputStream 0x5c8a3fe "java.lang.ProcessBuilder$NullOutputStream@5c8a3fe"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x4e6ccf1d "java.lang.ProcessBuilder$NullInputStream@4e6ccf1d"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x4e6ccf1d "java.lang.ProcessBuilder$NullInputStream@4e6ccf1d"], :prev nil, :cmd ["bin/tailwindcss" "-c" "resources/tailwind.config.js" "-i" "resources/tailwind.css" "-o" "target/resources/public/css/main.css" "--watch"]}, :task #'babashka.tasks/*task*, :babashka/exit 139}

Creating a new project, and running bb dev again leads to this error:

Rebuilding...
Error: Cannot find module '@tailwindcss/forms'
Require stack:
- /home/nate/Projects/Programming/misc/biff-tutorial/fifth/resources/tailwind.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Function.resolve (node:internal/modules/cjs/helpers:116:19)
    at _resolve (/usr/lib/node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:250334)
    at jiti (/usr/lib/node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:252917)
    at /home/nate/Projects/Programming/misc/biff-tutorial/fifth/resources/tailwind.config.js:9:5
    at evalModule (/usr/lib/node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:255614)
    at jiti (/usr/lib/node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:253542)
    at /usr/lib/node_modules/tailwindcss/lib/lib/load-config.js:37:30
    at loadConfig (/usr/lib/node_modules/tailwindcss/lib/lib/load-config.js:39:6)
    at Object.loadConfig (/usr/lib/node_modules/tailwindcss/lib/cli/build/plugin.js:135:49) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/nate/Projects/Programming/misc/biff-tutorial/fifth/resources/tailwind.config.js'
  ]
}
Error while executing task: css

System information

OS: Void Linux Processor: x86_64 Babashka : 1.3.182 Npm: 9.5.1

nate-sys commented 11 months ago

Got it to work by nuking my tailwind install and creating a new project. I don't know how to reproduce the issue, but I think it happens when the initial tailwind download fails when setting up a project. Maybe it tries to run the incomplete binary that didn't download correctly? Though, this doesn't explain why the pages just stopped being styled during my first run, where everything downloaded correctly. Curious.

jacobobryant commented 11 months ago

Interesting, I'll investigate this soon.

jacobobryant commented 11 months ago

I was able to reproduce the first error by running bb css on a new project and then hitting ctrl-c while the tailwind download was in progress, then doing chmod +x bin/tailwindcss. I added some code that will detect if the binary is corrupted and print an error message suggesting that you delete it if so (which will cause the binary to be redownloaded the next time you run the original command). That's on master already (see https://forum.tfos.co/t/biff-v0-7-13/81), and I'll publish a release on github soon.

As for how your tailwind binary got in that state after it was already working, I have no idea... but if it ever resurfaces, rm bin/tailwindcss should do the trick.

The Cannot find module '@tailwindcss/forms' error is there because the default tailwind.config.js file specifies a dependency on the @tailwindcss/forms plugin, which is bundled with the binary. If you've installed tailwindcss locally or globally with npm, you'll need to also install @tailwindcss/forms with npm.