cljminecraft

cljminecraft

0 Downloads

clj-minecraft + Light Table -> crash

slaf4 opened this issue · 4 comments

commented

I am trying to modify clj-minecraft to use it with Light Table nREPL by using the instructions of this link: http://manuelp.herokuapp.com/category/nrepl.

To have a LT-aware nREPL server, we have first to add a dependency to the LT middleware in project.clj

(defproject cljminecraft “1.0.6-SNAPSHOT”
:description “Clojure for Bukkit Minecraft”
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/tools.logging "0.2.6"]
[org.clojure/tools.nrepl "0.2.3"]
[org.bukkit/bukkit "1.6.4-R2.0"]
[clojure-complete "0.2.3"]
[cheshire "5.2.0"]
[org.reflections/reflections "0.9.8"]
[lein-light-nrepl "0.0.15"]] <———————– LT dependency
:profiles {:dev {:dependencies []}}
:javac-options [ "-d" "classes/" "-source" "1.6" "-target" "1.6"]
:java-source-paths ["javasrc"]
:uberjar-exclusions [#"(org|com|gnu)//"

"com[/]google[/]common/"

"org[/]apache[/]commons/"

"javax[/]persistence/"

"net[/]sf[/]cglib/"]

:repositories [["bukkit.snapshots" "http://repo.bukkit.org/content/repositories/snapshots"%5D
["bukkit.release" "http://repo.bukkit.org/content/repositories/releases"%5D%5D
)
-> After adding this dependency, if I ‘lein uberjar’, copy ‘cljminecraft-1.0.6-SNAPSHOT-standalone’ in the plugins and restart ‘craftbukkit-1.7.2-R0.2 Beta’ server, the clojure plugin is not crashing but to connect LT to the plugin, we have to also add the middlewares chains in the code:
(ns cljminecraft.core
(:require [cljminecraft.bukkit :as bk]
[cljminecraft.blocks :as blocks]
[cljminecraft.events :as ev]
[cljminecraft.entity :as ent]
[cljminecraft.player :as plr]
[cljminecraft.util :as util]
[cljminecraft.logging :as log]
[cljminecraft.config :as cfg]
[cljminecraft.commands :as cmd]
[cljminecraft.recipes :as r]
[cljminecraft.items :as i]
[cljminecraft.files]
[clojure.tools.nrepl.server :refer (start-server stop-server)]
[lighttable.nrepl.handler :refer [lighttable-ops]] <———— middlewares chains
))
After adding the middlewares chains in the code, I did ‘lein uberjar’, copied ‘cljminecraft-1.0.6-SNAPSHOT-standalone’ in the plugins and restarted the ‘craftbukkit-1.7.2-R0.2 Beta’ server. Doing that I got the message ‘Something broke setting up Clojure’ -> clojure in the crafbukkit server crashed.

I use LightTable 0.6.2. (0.8.4). I am just starting to learn clojure and Light Table and I am not a professional programmer, so I am probably missing something obvious.. Any idea how I can troubleshoot that?

commented

I managed to enable nrepl middleware for cider (repl for emacs), in this branch. However, without two parts of this middleware: format and tracker, that are causing problems during compile. Repl works, including autocomplete and other nice features.

There's hack mentioned in cider nrepl readme:

(extend org.bukkit.plugin.java.PluginClassLoader
  cp/DynamicClasspath
  (assoc cp/base-readable-addable-classpath
         :classpath-urls #(seq (.getURLs %))
         :can-add? (constantly false)))

I don't understand how it works, it does some magic to bukkit's classloader. With it, and with two imports disabled, cider middleware were able to load.

I just tried to do the same for lighttable's repl middleware and it doesn't work:

[23:29:58 WARN]: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil, compiling:(lighttable/nrepl/cljs.clj:76:1)
[23:29:58 WARN]:    at clojure.lang.Compiler.load(Compiler.java:7239)
[23:29:58 WARN]:    at clojure.lang.RT.loadResourceScript(RT.java:371)
[23:29:58 WARN]:    at clojure.lang.RT.loadResourceScript(RT.java:362)
[23:29:58 WARN]:    at clojure.lang.RT.load(RT.java:446)
[23:29:58 WARN]:    at clojure.lang.RT.load(RT.java:412)
[23:29:58 WARN]:    at clojure.core$load$fn__5448.invoke(core.clj:5866)
[23:29:58 WARN]:    at clojure.core$load.doInvoke(core.clj:5865)
[23:29:58 WARN]:    at clojure.lang.RestFn.invoke(RestFn.java:408)
[23:29:58 WARN]:    at clojure.core$load_one.invoke(core.clj:5671)
[23:29:58 WARN]:    at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
[23:29:58 WARN]:    at clojure.core$load_lib.doInvoke(core.clj:5710)
[23:29:58 WARN]:    at clojure.lang.RestFn.applyTo(RestFn.java:142)
[23:29:58 WARN]:    at clojure.core$apply.invoke(core.clj:632)
[23:29:58 WARN]:    at clojure.core$load_libs.doInvoke(core.clj:5749)
[23:29:58 WARN]:    at clojure.lang.RestFn.applyTo(RestFn.java:137)
[23:29:58 WARN]:    at clojure.core$apply.invoke(core.clj:632)
[23:29:58 WARN]:    at clojure.core$require.doInvoke(core.clj:5832)
[23:29:58 WARN]:    at clojure.lang.RestFn.invoke(RestFn.java:1289)
[23:29:58 WARN]:    at lighttable.nrepl.handler$eval6902$loading__5340__auto____6903.invoke(handler.clj:1)
[23:29:58 WARN]:    at lighttable.nrepl.handler$eval6902.invoke(handler.clj:1)
[23:29:58 WARN]:    at clojure.lang.Compiler.eval(Compiler.java:6782)
[23:29:58 WARN]:    at clojure.lang.Compiler.eval(Compiler.java:6771)
...
commented

Hi slaf4

To be entirely honest, I haven't had the best of luck integrating the LightTable middleware into my existing projects either, so I'm probably not particularly well equipped to help much.

One thing you may need to do is check here https://github.com/CmdrDats/clj-minecraft/blob/master/src/cljminecraft/core.clj#L27 where the nrepl server is started - I think you need to refer to the middleware somehow?

Only problem is that that probably won't solve your 'something broke setting up Clojure' message - that gets thrown over here https://github.com/CmdrDats/clj-minecraft/blob/master/javasrc/cljminecraft/ClojurePlugin.java#L27, usually when there's some kind of clojure compilation problem.

Sorry I can't be of more help. Let me know if you do manage to figure it out though!

commented

Hi CmdrDats,
Thank you to have taken the time to answer my issue.
At the moment I don't have the knowledge and the experience to solve a clojure compilation problem.
I am using you project to initiate my son to clojure programming.
He is enjoying playing with minecraft (me too).
I showed how we can with clojure make a cow, a sheep, etc appeared in front of the avatar.
It is just a beginning but we are enjoying it.
Thank you to have made clj-minecraft available to everyboby.
I am sure a lot of work was involved in this project.
Regards.

commented

Hi slaf4,

That's awesome! This is the exactly kind of thing I was hoping clj-minecraft would be used for :) Sorry I can't help out more on fixing light table integration though - I'm still trying to get it to work with my other projects, without much luck.

It's been a lot of fun building this and am keen to hear how it's being used - so be sure to fill me in on your adventures! :)

Cheers!