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

Exception from babashka.nrepl.server require in com.platypub.themes.common #73

Closed
jeffp42ker opened this issue Sep 2, 2022 · 5 comments

Comments

@jeffp42ker
Copy link
Contributor

jeffp42ker commented Sep 2, 2022

My site theme reuses much of the default theme and works fine in dev.

However doing a "Force refresh" in production, the babashka.nrepl.server namespace required (and not used) in the default theme common.clj is not found, throwing an Exception:

Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: "Elapsed time: 3712.302363 msecs"
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: [qtp517066272-15] INFO com.platypub.feat.sites - ----- Error --------------------------------------------------------------------
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: Type:     java.lang.Exception
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: Message:  Could not find namespace: babashka.nrepl.server.
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: Location: /home/app/.gitlibs/libs/com.platypub.themes/default/833b7c850f9f0cd206ad77373c6411cdd9a97fed/themes/default/src/com/platypub/themes/common.clj:2:3
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: ----- Context ------------------------------------------------------------------
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: 1: (ns com.platypub.themes.common
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: 2:   (:require [hiccup2.core :as hiccup]
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]:      ^--- Could not find namespace: babashka.nrepl.server.
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: 3:             [hiccup.util :refer [raw-string]]
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: 4:             [babashka.fs :as fs]
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: 5:             [babashka.nrepl.server :as nrepl]
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: 6:             [cheshire.core :as cheshire]
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: 7:             [clojure.edn :as edn]
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: ----- Stack trace --------------------------------------------------------------
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: com.platypub.themes.common        - /home/app/.gitlibs/libs/com.platypub.themes/default/833b7c850f9f0cd206ad77373c6411cdd9a97fed/themes/default/src/com/platypub/themes/common.clj:2:3
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: nyc.jeffparker.jackies-theme.site - /home/app/storage/previews/e00ca9b7-4a8b-4c1c-82e6-f2c0e13da077/src/nyc/jeffparker/jackies_theme/site.clj:2:3
Sep 02 20:40:38 biffweb-jpnyc-ubuntu-s-1vcpu-1gb-nyc1-01 task[290249]: [qtp517066272-15] INFO com.biffweb.impl.middleware - 13386ms 404 get  /sites/e00ca9b7-4a8b-4c1c-82e6-f2c0e13da077/preview?force=true&path=/

"Preview" 404's

I'm using the latest bb version in both environments:

$ bb --version
babashka v0.9.161

I tried removing the unused [babashka.nrepl.server :as nrepl] require yet it still shows up for some reason.

Also ran the suggestion in #72 to no avail.

$ pwd
/home/app
$ cd themes/default
$ bb --force -e nil
$ cd ../jackies-theme
$ bb --force -e nil
$ exit
@jacobobryant
Copy link
Owner

jacobobryant commented Sep 3, 2022

EDIT: just noticed you're already on v0.9.161 on both environments.

I was going to say "wow, I haven't seen this one yet"--but then I just remembered that when I was first getting bb tasks set up I had to upgrade babashka to get the nrepl server to work. I guess it wasn't bundled in earlier versions. Maybe you have a newer version of bb locally and that's why it only breaks on the server? I have v0.9.161 locally and v0.8.157 on my server.

If that fixes it, I'll add this to my list of things to mention when I update the platypub docs. I'm hoping to spend next weekend on those. (I think bb.edn also supports specifying a minimum bb version which might be handy.)

@jacobobryant
Copy link
Owner

The nrepl code is used in the .../common/tasks.clj file. I must've forgotten to remove the require when I moved it from common.clj to tasks.clj. I'm guessing that's why you still get the error even when removing it from common.clj. (However--if you're updating the default theme code, you'll need to make sure your custom theme's deps.edn file depends on the default theme with a local dependency instead of a git dependency, otherwise the change won't apply).

In any case... not sure what's causing the error. Can you run bb -e "(require '[babashka.nrepl.server])" successfully?

@jacobobryant
Copy link
Owner

If all else fails (or if you want to work on your theme and not on weird platypub/babashka errors), you could copy all the code from tasks.clj into your own custom tasks.clj file, get rid of the nrepl stuff, and then update your bb.edn so it uses your custom tasks.clj file instead of the default theme's. And change the default theme dependency sha to e4af4618d7eaaa969d28bda3a60237672adbb72b, which no longer includes the nrepl require in common.clj. Obviously hopefully we can fix the root problem though.

Another workaround would be to just add a src/babashka/nrepl/server.clj file and define a start-server! function that does a no-op.

@jeffp42ker
Copy link
Contributor Author

In any case... not sure what's causing the error. Can you run bb -e "(require '[babashka.nrepl.server])" successfully?

Yes. And I too was on Babashka v0.8.157 or similar on the server before upgrading it yesterday.

And change the default theme dependency sha to e4af461, which no longer includes the nrepl require in common.clj. Obviously hopefully we can fix the root problem though.

Changing the default theme dependency sha fixed it; no other changes needed.

I'm happy to close the issue now and re-open if you want to find the root problem.

@jacobobryant
Copy link
Owner

jacobobryant commented Sep 3, 2022

Huh. I'm surprised that would fix it but the bb --force thing wouldn't.
I have a bad feeling I'm gonna have to learn more about Babashka internals sooner or later ha-ha-ha.
I might mention some of these things over in #babashka at some point.

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

No branches or pull requests

2 participants