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

Error handling for missing tailwindcss executable #530

Merged
merged 2 commits into from
Jul 24, 2023
Merged

Error handling for missing tailwindcss executable #530

merged 2 commits into from
Jul 24, 2023

Conversation

mk
Copy link
Member

@mk mk commented Jun 30, 2023

Fixes #507.

@mk
Copy link
Member Author

mk commented Jun 30, 2023

Added a9336a1 because the error message is (imo) better. Before:

mk@mkair ~/d/clerk (fix-507) [1]> clj -X:nextjournal/clerk :paths '["notebooks/rule_30.clj"]' :compile-css true
[info] both `:paths` and `:paths-fn` are set, `:paths` will take precendence.
👷🏼 Clerk is building 1 notebooks…
🧐 Parsing… Done in 92.608ms. ✅
🔬 Analyzing… Done in 2002.903ms. ✅
🔨 Building "notebooks/rule_30.clj"… Done in 137.645ms. ✅
🎨 Compiling CSS… {:clojure.main/message
 "Execution error (IOException) at java.lang.ProcessImpl/forkAndExec (ProcessImpl.java:-2).\nerror=2, No such file or directory\n",
 :clojure.main/triage
 {:clojure.error/class java.io.IOException,
  :clojure.error/line -2,
  :clojure.error/cause "error=2, No such file or directory",
  :clojure.error/symbol java.lang.ProcessImpl/forkAndExec,
  :clojure.error/source "ProcessImpl.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.Exception,
    :message
    "Clerk could not find the `tailwindcss` executable. Please install it using `npm install -D tailwindcss` and try again.",
    :at
    [nextjournal.clerk.builder$compile_css_BANG_$fn__17347
     invoke
     "builder.clj"
     317]}
   {:type java.io.IOException,
    :message
    "Cannot run program \"tailwindcsss\": error=2, No such file or directory",
    :at [java.lang.ProcessBuilder start "ProcessBuilder.java" 1143]}
   {:type java.io.IOException,
    :message "error=2, No such file or directory",
    :at [java.lang.ProcessImpl forkAndExec "ProcessImpl.java" -2]}],
  :trace
  [[java.lang.ProcessImpl forkAndExec "ProcessImpl.java" -2]
   [java.lang.ProcessImpl <init> "ProcessImpl.java" 319]
   [java.lang.ProcessImpl start "ProcessImpl.java" 249]
   [java.lang.ProcessBuilder start "ProcessBuilder.java" 1110]
   [java.lang.ProcessBuilder start "ProcessBuilder.java" 1073]
   [babashka.process$process_STAR_ invokeStatic "process.cljc" 357]
   [babashka.process$process_STAR_ invoke "process.cljc" 329]
   [babashka.process$sh invokeStatic "process.cljc" 554]
   [babashka.process$sh doInvoke "process.cljc" 544]
   [clojure.lang.RestFn invoke "RestFn.java" 619]
   [nextjournal.clerk.builder$compile_css_BANG_$fn__17347
    invoke
    "builder.clj"
    317]
   [nextjournal.clerk.builder$compile_css_BANG_
    invokeStatic
    "builder.clj"
    317]
   [nextjournal.clerk.builder$compile_css_BANG_
    invoke
    "builder.clj"
    298]
   [nextjournal.clerk.builder$build_static_app_BANG_
    invokeStatic
    "builder.clj"
    414]
   [nextjournal.clerk.builder$build_static_app_BANG_
    invoke
    "builder.clj"
    369]
   [nextjournal.clerk$build_BANG_ invokeStatic "clerk.clj" 509]
   [nextjournal.clerk$build_BANG_ invoke "clerk.clj" 467]
   [clojure.lang.Var invoke "Var.java" 384]
   [clojure.run.exec$exec invokeStatic "exec.clj" 89]
   [clojure.run.exec$exec invoke "exec.clj" 78]
   [clojure.run.exec$_main$fn__219 invoke "exec.clj" 216]
   [clojure.run.exec$_main invokeStatic "exec.clj" 212]
   [clojure.run.exec$_main doInvoke "exec.clj" 180]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "error=2, No such file or directory"}}

Execution error (IOException) at java.lang.ProcessImpl/forkAndExec (ProcessImpl.java:-2).
error=2, No such file or directory

after

mk@mkair ~/d/clerk (fix-507) [1]> clj -X:nextjournal/clerk :paths '["notebooks/rule_30.clj"]' :compile-css true
[info] both `:paths` and `:paths-fn` are set, `:paths` will take precendence.
👷🏼 Clerk is building 1 notebooks…
🧐 Parsing… Done in 117.607ms. ✅
🔬 Analyzing… Done in 1967.063ms. ✅
🔨 Building "notebooks/rule_30.clj"… Done in 130.027ms. ✅
🎨 Compiling CSS… {:clojure.main/message
 "Execution error at nextjournal.clerk.builder/compile-css!$fn (builder.clj:317).\nClerk could not find the `tailwindcss` executable. Please install it using `npm install -D tailwindcss` and try again.\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.Exception,
  :clojure.error/line 317,
  :clojure.error/cause
  "Clerk could not find the `tailwindcss` executable. Please install it using `npm install -D tailwindcss` and try again.",
  :clojure.error/symbol nextjournal.clerk.builder/compile-css!$fn,
  :clojure.error/source "builder.clj",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.Exception,
    :message
    "Clerk could not find the `tailwindcss` executable. Please install it using `npm install -D tailwindcss` and try again.",
    :at
    [nextjournal.clerk.builder$compile_css_BANG_$fn__17347
     invoke
     "builder.clj"
     317]}],
  :trace
  [[nextjournal.clerk.builder$compile_css_BANG_$fn__17347
    invoke
    "builder.clj"
    317]
   [nextjournal.clerk.builder$compile_css_BANG_
    invokeStatic
    "builder.clj"
    317]
   [nextjournal.clerk.builder$compile_css_BANG_
    invoke
    "builder.clj"
    298]
   [nextjournal.clerk.builder$build_static_app_BANG_
    invokeStatic
    "builder.clj"
    414]
   [nextjournal.clerk.builder$build_static_app_BANG_
    invoke
    "builder.clj"
    369]
   [nextjournal.clerk$build_BANG_ invokeStatic "clerk.clj" 509]
   [nextjournal.clerk$build_BANG_ invoke "clerk.clj" 467]
   [clojure.lang.Var invoke "Var.java" 384]
   [clojure.run.exec$exec invokeStatic "exec.clj" 89]
   [clojure.run.exec$exec invoke "exec.clj" 78]
   [clojure.run.exec$_main$fn__219 invoke "exec.clj" 216]
   [clojure.run.exec$_main invokeStatic "exec.clj" 212]
   [clojure.run.exec$_main doInvoke "exec.clj" 180]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause
  "Clerk could not find the `tailwindcss` executable. Please install it using `npm install -D tailwindcss` and try again."}}

Execution error at nextjournal.clerk.builder/compile-css!$fn (builder.clj:317).
Clerk could not find the `tailwindcss` executable. Please install it using `npm install -D tailwindcss` and try again.

Or do folks have a better idea? cc @hiredman.

@zampino zampino merged commit c93e084 into main Jul 24, 2023
@zampino zampino deleted the fix-507 branch July 24, 2023 10:09
"--output" tw-output
"--minify")
(catch java.io.IOException _
(throw (Exception. "Clerk could not find the `tailwindcss` executable. Please install it using `npm install -D tailwindcss` and try again."))))]
Copy link
Member Author

Choose a reason for hiding this comment

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

The install hint in the error is actually not correct which is why I didn't merge it. We currently only rely on the standalone tailwindcss executable, so installing it via npm install -D tailwindcss won't work (we'd need to call it via npx then). Do we want to support both installation methods?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, maybe relying on the standalone executable was a mistake (see also https://github.com/nextjournal/clerk/blob/d80187013d7b7b96db3d8b114b8d99f687170668/.github/workflows/main.yml#L201-L200).

Maybe we could probe the exit code of npx tailwindcss and then fallback to tailwindcss for legacy projects?

Actually we need npm install -D tailwindcss @tailwindcss/typography with our config.

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.

document build! with :compile-css requiring tailwind executable
2 participants