Fork me on GitHub
#biff
<
2023-03-02
>
James Pratt19:03:43

I am getting an error when running bb dev, testing out the eelchat code on my laptop. It was working but has stopped working. Error below. I'm not sure how to debug this:

bb dev

Rebuilding...

Done in 120ms.
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate __init.class, .clj or .cljc on classpath.

Full report at:
/var/folders/lv/zql5shxs6j75gfp84cgfmm240000gn/T/clojure-1878455090635687364.edn
Error while executing task: dev

James Pratt19:03:29

Ah, the full report referred to is:

{:clojure.main/message
 "Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate __init.class, .clj or .cljc on classpath.\n",
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line 40,
  :clojure.error/cause
  "Could not locate __init.class, .clj or .cljc on classpath.",
  :clojure.error/symbol clojure.main/main,
  :clojure.error/source "main.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message
    "Could not locate __init.class, .clj or .cljc on classpath.",
    :at [clojure.lang.RT load "RT.java" 462]}],
  :trace
  [[clojure.lang.RT load "RT.java" 462]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6908 invoke "core.clj" 6161]
   [clojure.core$load invokeStatic "core.clj" 6160]
   [clojure.core$load doInvoke "core.clj" 6144]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5933]
   [clojure.core$load_one invoke "core.clj" 5928]
   [clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
   [clojure.core$load_lib invokeStatic "core.clj" 5974]
   [clojure.core$load_lib doInvoke "core.clj" 5953]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 6016]
   [clojure.core$load_libs doInvoke "core.clj" 6000]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 6038]
   [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 "Could not locate __init.class, .clj or .cljc on classpath."}}

James Pratt19:03:05

java --version
openjdk 19.0.2 2023-01-17
OpenJDK Runtime Environment Homebrew (build 19.0.2)
OpenJDK 64-Bit Server VM Homebrew (build 19.0.2, mixed mode, sharing)

James Pratt19:03:53

Using an M1 Macbook.

Jacob O'Bryant19:03:05

hm, looks like the main namespace being passed to clojure isn't there. what does bb run-args print out?

James Pratt19:03:06

bb run-args
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  File does not exist: run-args

Jacob O'Bryant19:03:59

Oh, forgot that's just a function, not a task you can call with bb. What's the contents of config.edn (the :tasks section specifically)? (On the process for debugging this: the source code for bb tasks in here: https://github.com/jacobobryant/biff/blob/master/tasks/src/com/biffweb/tasks.clj#L128 -- the last command in the dev task basically just calls clj and passes the result of (run-args) as the parameters. and (run-args) just returns the value of the :biff.tasks/clj-args option in config.edn.)

James Pratt19:03:14

bb run-cmd
clj -J-XX:-OmitStackTraceInFastThrow -M -m nil --port 7888 --middleware [cider.nrepl/cider-middleware]

Jacob O'Bryant19:03:54

ah yes, the -M -m nil is the problem. probably need to make a change to config.edn

Jacob O'Bryant19:03:14

(it should be e.g. -M -m com.eelchat , or whatever your main namespace is)

James Pratt19:03:19

strange that it worked previously

Jacob O'Bryant19:03:35

what's the current contents of config.edn?

James Pratt19:03:35

;; vim: ft=clojure
{:prod {:biff.xtdb/dir "storage/xtdb"
        :biff.xtdb/topology :standalone
        ;; Standalone topology in production isn't recommended for anything
        ;; serious. You can uncomment the following to use managed postgres
        ;; instead.
        ;; :biff.xtdb/topology :jdbc
        ;; :biff.xtdb.jdbc/jdbcUrl ":port/dbname?sslmode=require"
        :biff/base-url ""
        ;; Postmark is used to send email sign-in links. Create an account at
        ;; 
        :postmark/api-key nil
        ;; Change to the address of your sending identity. Set a reply-to
        ;; address on your sending identity if you want to receive replies and
        ;; your from address isn't configured for receiving.
        :postmark/from ""
        ;; Recaptcha is used to protect your sign-in page. Go to
        ;;  and add a site. Select v2
        ;; invisible. Add localhost to your list of allowed domains.
        :recaptcha/site-key nil
        :recaptcha/secret-key nil
        :biff.middleware/cookie-secret "CLqrhUIs3ognUgE2L0MzlQ=="
        :biff/jwt-secret "EKYVphKYh0eprK6K/7HPsrMH22MgkcRRgHxHj8w+YXk="}
 :dev {:merge [:prod]
       :com.eelchat/enable-beholder true
       :biff/host "0.0.0.0"
       :biff/port 8080
       :biff/base-url ""
       :biff.xtdb/topology :standalone
       :biff.middleware/secure false}
 :tasks {;; Set this if the auto-detection doesn't work
         ;; Possible values: macos-x64, macos-arm64, linux-x64, linux-arm64
         :biff.tasks/tailwind-build nil
         :biff.tasks/clj-args ["-J-XX:-OmitStackTraceInFastThrow"
                               "-J-XX:+CrashOnOutOfMemoryError"
                               "-M" "-m" "com.eelchat"
                               "--port" "7888"
                               "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]
         :biff.tasks/soft-deploy-fn com.eelchat/on-save
         ;; Uncomment this if your primary branch is called main instead of master.
         ;:biff.tasks/deploy-cmd ["git" "push" "prod" "main:master"]
         :biff.tasks/deploy-cmd ["git" "push" "prod" "master"]
         :biff.tasks/server ""}}

Jacob O'Bryant19:03:28

what's the contents of tasks/deps.edn ? config.edn looks correct. maybe it's something to do with the biff version...

James Pratt19:03:59

{:paths ["src"]
 :deps {com.biffweb/tasks {:git/url "" :sha "9d725ba74514032b3a6f86affe16f8d3c9693135" :deps/root "tasks"}}}

James Pratt19:03:16

I used this command to set up the project:

bb -e "$(curl -s )" tutorial

James Pratt19:03:17

then I have been overwriting tracked files with contents of repo

James Pratt19:03:28

at different commits

James Pratt19:03:55

git remote -v
origin	 (fetch)
origin	 (push)

James Pratt19:03:35

thanks so much for your help by the way!!

🙌 2
James Pratt19:03:50

great to have such quick response from the author!!

James Pratt19:03:24

biff seems great, very interesting, thanks for putting htmx on my radar

Jacob O'Bryant19:03:13

ah, that could do it. The bb -e "$(curl -s )" tutorial actually uses a somewhat more recent version of biff than what's on that repo. So in doing that you've ended up downgrading the biff version in deps.edn (and more importantly, tasks/deps.edn) to an older version than what your project was created with. And the reason that causes problems is because the config.edn file (which isn't tracked by git) was generated by the new version of biff, and that causes a compatibility problem (new code is compatible with old config, but not always the other way around). I think it'll work if you just set the last section of config.edn to this:

:tasks {;; Set this if the auto-detection doesn't work
         ;; Possible values: macos-x64, macos-arm64, linux-x64, linux-arm64
         :biff.tasks/tailwind-build nil
         :biff.tasks/main-ns com.eelchat
         :biff.tasks/soft-deploy-fn com.eelchat/on-save
         :biff.tasks/deploy-from "master"
         :biff.tasks/deploy-to "prod"
         :biff.tasks/server ""}

Jacob O'Bryant19:03:16

You're welcome!

Jacob O'Bryant19:03:08

similar issues have come up before -- I'm gonna push a config.edn.TEMPLATE file to the eelchat repo; so anyone going off the repo version of eelchat can just use that

Jacob O'Bryant19:03:43

(if you deploy eelchat, replace in that snippet with your own domain)

James Pratt19:03:14

great, that fixes the problem!

🎉 2
James Pratt19:03:21

thanks a lot for the emergency resuscitation

James Pratt19:03:48

will continue investigating how you have web sockets working with htmx

Jacob O'Bryant19:03:08

(also another note--I was actually a bit careless in having you paste config.edn, since it contains some secrets, jwt-secret and cookie-secret. newer versions of biff keep the secrets in secrets.env, so config.edn is safe to paste for new projects. in any case since it's just a tutorial, probably no big deal, but fyi for future reference!)

James Pratt19:03:11

which is what I'm poking around to look at

James Pratt19:03:46

am just using on local development machine

James Pratt19:03:50

won't be deploying

👍 2
Jacob O'Bryant19:03:00

sounds good, let me know if you have any questions about that. this thread might be useful: https://clojurians.slack.com/archives/C013Y4VG20J/p1676576376740459

James Pratt19:03:17

cheers!

🎅 2