biff 2024-07-07

couple of questions about tasks in biff: 1. I notice some duplication (I dont think duplication's the right word, but at least it conveys some sense of what I'm seeing) between https://github.com/jacobobryant/biff/blob/release/libs/tasks/src/com/biffweb/tasks.clj, and https://github.com/jacobobryant/biff/blob/release/tasks/src/com/biffweb/tasks.clj. Why is this necessary and when is each file used? 2. when attempting to run clj -M:dev deploy, I hit an issue with ssh (`root@<IP_ADDRESS>: Permission denied (publickey).`). From the output and the result on the server, it looks like it would be the restart subtask for deploy. a. first up, YES, the ssh issue is totally expected, and fine, IF root were to be necessary (I've set up restrictions on which users can ssh in by using AllowUsers in sshd_config) b. but the question is, why root? do we specifically need to do anything as root? I see in server-setup.sh that we've granted permissions for the app user to be able to restart the app already The output from clj -M:dev deploy:

$ clj -M:dev deploy
Identity added: /Users/jf/.ssh/id_ed25519 (jf@)
Started an ssh-agent session. If you set up `keychain`, you won't have to enter your password each time you run this command: 
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: 

Rebuilding...

Done in 164ms.
building file list ... done
.dockerignore
.gitignore
Dockerfile
README.md
cljfmt-indents.edn
config.env
deps.edn
server-setup.sh
dev/
dev/repl.clj
dev/tasks.clj
resources/
resources/config.edn
resources/config.template.env
...
sent 148760 bytes  received 1106 bytes  59946.40 bytes/sec
total size is 145095  speedup is 0.97
root@: Permission denied (publickey).
Exception in thread "main" java.lang.IllegalArgumentException: Multiple methods in multimethod 'simple-dispatch' match dispatch value: class babashka.process.Process -> interface clojure.lang.IDeref and interface clojure.lang.IPersistentMap, and neither is preferred
        at clojure.lang.MultiFn.findAndCacheBestMethod(MultiFn.java:179)
        at clojure.lang.MultiFn.getMethod(MultiFn.java:150)
        at clojure.lang.MultiFn.getFn(MultiFn.java:154)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_map$fn__11151$fn__11153.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map$fn__11151.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:112)
        at clojure.pprint$pprint_map.invoke(dispatch.clj:106)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_vector$fn__11136.invoke(dispatch.clj:95)
        at clojure.pprint$pprint_vector.invokeStatic(dispatch.clj:94)
        at clojure.pprint$pprint_vector.invoke(dispatch.clj:92)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_map$fn__11151$fn__11153.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map$fn__11151.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:112)
        at clojure.pprint$pprint_map.invoke(dispatch.clj:106)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_map$fn__11151$fn__11153.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map$fn__11151.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:112)
        at clojure.pprint$pprint_map.invoke(dispatch.clj:106)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint$fn__10392.invoke(pprint_base.clj:249)
        at clojure.pprint$pprint.invokeStatic(pprint_base.clj:248)
        at clojure.pprint$pprint.invoke(pprint_base.clj:241)
        at clojure.pprint$pprint.invokeStatic(pprint_base.clj:245)
        at clojure.pprint$pprint.invoke(pprint_base.clj:241)
        at clojure.lang.Var.invoke(Var.java:384)
        at clojure.main$report_error$fn__9280$fn__9281.invoke(main.clj:603)
        at clojure.main$report_error$fn__9280.invoke(main.clj:602)
        at clojure.main$report_error.invokeStatic(main.clj:601)
        at clojure.main$main.invokeStatic(main.clj:666)
        at clojure.main$main.doInvoke(main.clj:616)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:40)

1. the second file was used previously when Biff used bb tasks by default--I.e. it's a babashka file actually. it's only there for backwards compatibility now. the first file is the main one. 2. I think running the ssh commands as root was just an oversight, agreed they should run as app. I'll go ahead and push a commit to fix that next time I get a minute.

👌 1
🙏 1

I just pushed a commit that ignores directories in :biff/eval-paths if they aren't on the classpath (https://github.com/jacobobryant/biff/commit/a1d53efdab2046134575b71ed35a51fbcd212600). So you can just upgrade to that; no need to edit resources/config.edn: {:git/sha "a1d53ef", :git/tag "v1.8.21", ...}

thank you Jacob! that removes that issue from the output for clj -M:dev soft-deploy. I just noticed though that my own local server also has some output while the deploy is going on; I'm not as concerned about it, but it is there, fyi:

:reloading (com.eelchat-test)
:error-while-loading com.eelchat-test
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (com/eelchat_test.clj:26:19). {:clojure.error/phase :compile-syntax-check, :clojure.error/line 26, :clojure.error/column 19, :clojure.error/source "com/eelchat_test.clj"}
        clojure.lang.Compiler.analyze (Compiler.java:6825)
        clojure.lang.Compiler.analyze (Compiler.java:6762)
        clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3832)
        clojure.lang.Compiler.analyzeSeq (Compiler.java:7126)
        clojure.lang.Compiler.analyze (Compiler.java:6806)
        clojure.lang.Compiler.access$300 (Compiler.java:38)
        clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6401)
        clojure.lang.Compiler.analyzeSeq (Compiler.java:7124)
        clojure.lang.Compiler.analyze (Compiler.java:6806)
        clojure.lang.Compiler.analyzeSeq (Compiler.java:7112)
        clojure.lang.Compiler.analyze (Compiler.java:6806)
        clojure.lang.Compiler.analyze (Compiler.java:6762)
Caused by:
RuntimeException No such var: app/send-message
        clojure.lang.Util.runtimeException (Util.java:221)
        clojure.lang.Compiler.resolveIn (Compiler.java:7405)
        clojure.lang.Compiler.resolve (Compiler.java:7375)
        clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)
        clojure.lang.Compiler.analyze (Compiler.java:6785)
        clojure.lang.Compiler.analyze (Compiler.java:6762)

Testing clojure.core

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.

hi @foo, just following up on this, I have https://github.com/jacobobryant/biff/pull/221 ready if you want to take a look

Thanks, just merged. Sorry for letting this slip through the cracks.

You can set your biff deps to {:git/tag "v1.8.20", :git/sha "75fd9d7", ...}

Well thank you for being responsive, and helpful!! Much appreciated too for proactively telling me how to update!

🎅 1

sorry Jacob, but I just updated my biff dep to {com.biffweb/biff #:git{:url "", :sha "75fd9d733c95e42b06c8d1b0eed9bc5f326c6f1c", :tag "v1.8.20"} and just tried 'clj -M:dev soft-deploy', but am still seeing behaviour where ssh is attempted with root (and babashka?):

$ clj -M:dev soft-deploy
Identity added: /Users/jf/.ssh/<REDACTED>
Started an ssh-agent session. If you set up `keychain`, you won't have to enter your password each time you run this command: 
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: 

Rebuilding...

Done in 165ms.
building file list ... done
resources/public/css/main.css

sent 1,785 bytes  received 144 bytes  771.60 bytes/sec
total size is 158,871  speedup is 82.36
root@<REDACTED>: Permission denied (publickey).
Exception in thread "main" java.lang.IllegalArgumentException: Multiple methods in multimethod 'simple-dispatch' match dispatch value: class babashka.process.Process -> interface clojure.lang.IPersistentMap and interface clojure.lang.IDeref, and neither is preferred
        at clojure.lang.MultiFn.findAndCacheBestMethod(MultiFn.java:179)
        at clojure.lang.MultiFn.getMethod(MultiFn.java:150)
        at clojure.lang.MultiFn.getFn(MultiFn.java:154)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_map$fn__11151$fn__11153.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map$fn__11151.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:112)
        at clojure.pprint$pprint_map.invoke(dispatch.clj:106)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_vector$fn__11136.invoke(dispatch.clj:95)
        at clojure.pprint$pprint_vector.invokeStatic(dispatch.clj:94)
        at clojure.pprint$pprint_vector.invoke(dispatch.clj:92)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_map$fn__11151$fn__11153.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map$fn__11151.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:112)
        at clojure.pprint$pprint_map.invoke(dispatch.clj:106)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint_map$fn__11151$fn__11153.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map$fn__11151.invoke(dispatch.clj:113)
        at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:112)
        at clojure.pprint$pprint_map.invoke(dispatch.clj:106)
        at clojure.lang.MultiFn.invoke(MultiFn.java:229)
        at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
        at clojure.pprint$pprint$fn__10392.invoke(pprint_base.clj:249)
        at clojure.pprint$pprint.invokeStatic(pprint_base.clj:248)
        at clojure.pprint$pprint.invoke(pprint_base.clj:241)
        at clojure.pprint$pprint.invokeStatic(pprint_base.clj:245)
        at clojure.pprint$pprint.invoke(pprint_base.clj:241)
        at clojure.lang.Var.invoke(Var.java:384)
        at clojure.main$report_error$fn__9280$fn__9281.invoke(main.clj:603)
        at clojure.main$report_error$fn__9280.invoke(main.clj:602)
        at clojure.main$report_error.invokeStatic(main.clj:601)
        at clojure.main$main.invokeStatic(main.clj:666)
        at clojure.main$main.doInvoke(main.clj:616)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:40)
$

the biff dep you posted looks like it's from the main :deps section. there's second biff dep inside your :dev alias you need to update. the stack trace mentions babashka because the tasks still use some babashka libraries, but it is regular clojure.

right, I see that now. Thank you! (and thank you for the explanation about babashka as well) I updated the [:aliases :dev] key and retried soft-deploy and am now getting a new error:

$ clj -M:dev soft-deploy
Identity added: /Users/jf/.ssh/<REDACTED>
Started an ssh-agent session. If you set up `keychain`, you won't have to enter your password each time you run this command: 
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: 

Rebuilding...

Done in 158ms.
building file list ... done
resources/public/css/main.css
src/com/eelchat/
src/com/eelchat/home.clj

sent 2,564 bytes  received 232 bytes  1,118.40 bytes/sec
total size is 158,871  speedup is 56.82
:reloading (com.eelchat.schema com.eelchat.middleware com.eelchat.settings com.eelchat.ui.icons com.eelchat.ui  com.eelchat.home com.eelchat.email com.eelchat com.eelchat-test)
:error-while-loading com.eelchat-test
FileNotFoundException Could not locate com/eelchat_test__init.class, com/eelchat_test.clj or com/eelchat_test.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
        clojure.lang.RT.load (RT.java:462)
        clojure.lang.RT.load (RT.java:424)
        clojure.core/load/fn--6908 (core.clj:6161)
        clojure.core/load (core.clj:6160)
        clojure.core/load (core.clj:6144)
        clojure.core/load-one (core.clj:5933)
        clojure.core/load-one (core.clj:5928)
        clojure.core/load-lib/fn--6850 (core.clj:5975)
        clojure.core/load-lib (core.clj:5974)
        clojure.core/load-lib (core.clj:5953)
        clojure.core/apply (core.clj:669)
        clojure.core/load-libs (core.clj:6016)

Testing user

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
{:test 0, :pass 0, :fail 0, :error 0, :type :summary}
$
I just tested the server, and it does look like the code got reloaded though. Is this therefore an error I can ignore? My deps.edn for reference:
{:paths ["src" "resources" "target/resources"]
 :deps {com.biffweb/biff                    #:git{:url "", :sha "75fd9d733c95e42b06c8d1b0eed9bc5f326c6f1c", :tag "v1.8.20"}
        camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}
        metosin/muuntaja                    {:mvn/version "0.6.8"}
        ring/ring-defaults                  {:mvn/version "0.3.4"}
        org.clojure/clojure                 {:mvn/version "1.11.1"}

        ;; Notes on logging: 
        org.slf4j/slf4j-simple     {:mvn/version "2.0.0-alpha5"}
        org.slf4j/log4j-over-slf4j {:mvn/version "1.7.36"}
        org.slf4j/jul-to-slf4j     {:mvn/version "1.7.36"}
        org.slf4j/jcl-over-slf4j   {:mvn/version "1.7.36"}
        http-kit/http-kit          {:mvn/version "2.8.0"}}
 :aliases
 {:dev {:extra-deps {com.biffweb/tasks {:git/url "", :git/sha "75fd9d7", :git/tag "v1.8.20", :deps/root "libs/tasks"}}
        :extra-paths ["dev" "test"]
        :jvm-opts ["-XX:-OmitStackTraceInFastThrow"
                   "-XX:+CrashOnOutOfMemoryError"
                   "-Dbiff.env.BIFF_PROFILE=dev"]
        :main-opts ["-m" "com.biffweb.task-runner" "tasks/tasks"]}
  :prod {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"
                    "-XX:+CrashOnOutOfMemoryError"
                    "-Dbiff.env.BIFF_PROFILE=prod"]
         :main-opts ["-m" "com.eelchat"]}}}

>

:error-while-loading com.eelchat-test
> FileNotFoundException Could not locate com/eelchat_test__init.class, com/eelchat_test.clj or com/eelchat_test.cljc on classpath.
Interesting. Just poked around a bit and I think it may be a regression from this commit: https://github.com/jacobobryant/biff/commit/32640d260c63a0260352fa5053feb30eb3c7c542 I did that so tests would get loaded and run automatically in dev, but I think what's happening in prod is that clojure.tools.namespace.repl looks in the "test" directory for clojure files, finds com.example-test, and then tries to load it--which fails because in prod, "test" isn't on the classpath. Try putting :biff/eval-paths #profile {:dev ["src" "test"] :default ["src"]} in resources/config.edn (edit the existing key, since I think it should already be in there), then run clj -M:dev deploy so we're starting from a fresh process, then see if clj -M:dev soft-deploy works.