Pertanyaan Memulai dengan Datomic dan Clojure di Emacs


File project.clj saya terlihat seperti ini

(defproject cljs-template "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.4.0-beta4"]
                 [noir-cljs "0.3.0"]
                 [fetch "0.1.0-alpha2"]
                 [noir "1.3.0-beta2"]
                 [org.clojure/core.cache "0.5.0"]
                 [com.datomic/datomic "0.1.3142"
                  :exclusions [org.slf4j/slf4j-nop org.slf4j/slf4j-log4j12]]
                 [ch.qos.logback/logback-classic "1.0.1"]]
  :plugins [[lein-swank "1.4.3"]]
  ;:cljsbuild {:builds [{}]}
  :main ^{:skip-aot true} cljs-template.server)

dan /src/cljs_template/server.clj saya dimulai sebagai berikut:

(ns cljs-template.server
  (:require [noir.server :as server]
            [noir.cljs.core :as cljs]
            [cljs-template.tree :as tree])
  (:use [datomic.api :only [db q] :as d]))

Saya kemudian mulai swank, jalankan (in-ns 'cljs-template.server) di dalamnya, pindahkan kursor saya ke akhir pemanggilan fungsi (ns), dan coba jalankan metode (ns) menggunakan Ctrl-x Ctrl- e. Ketika saya melakukannya, saya mendapatkan kesalahan berikut.

No message.
  [Thrown class java.lang.ExceptionInInitializerError]

Restarts:
 0: [QUIT] Quit to the SLIME top level
 1: [CAUSE1] Invoke debugger on cause  org.apache.lucene.index.IndexWriterConfig [Thrown class java.lang.ClassNotFoundException]

Backtrace:
  0:    (Unknown Source) java.lang.Class.forName0
  1:      Class.java:247 java.lang.Class.forName
  2:        RT.java:2030 clojure.lang.RT.loadClassForName
  3:         RT.java:417 clojure.lang.RT.load
  4:         RT.java:398 clojure.lang.RT.load
  5:       core.clj:5386 clojure.core/load[fn]
  6:       core.clj:5385 clojure.core/load
  7:     RestFn.java:408 clojure.lang.RestFn.invoke
  8:       core.clj:5200 clojure.core/load-one
  9:       core.clj:5237 clojure.core/load-lib
 10:     RestFn.java:142 clojure.lang.RestFn.applyTo
 11:        core.clj:602 clojure.core/apply
 12:       core.clj:5271 clojure.core/load-libs
 13:     RestFn.java:137 clojure.lang.RestFn.applyTo
 14:        core.clj:602 clojure.core/apply
 15:       core.clj:5352 clojure.core/require
 16:     RestFn.java:436 clojure.lang.RestFn.invoke
 17: fulltext_index.clj:4 datomic.fulltext-index/loading
 18:    (Unknown Source) datomic.fulltext_index__init.load
 19:    (Unknown Source) datomic.fulltext_index__init.<clinit>
 20:    (Unknown Source) java.lang.Class.forName0
 21:      Class.java:247 java.lang.Class.forName
 22:        RT.java:2030 clojure.lang.RT.loadClassForName
 23:         RT.java:417 clojure.lang.RT.load
 24:         RT.java:398 clojure.lang.RT.load
 25:       core.clj:5386 clojure.core/load[fn]
 26:       core.clj:5385 clojure.core/load
 27:     RestFn.java:408 clojure.lang.RestFn.invoke
 28:       core.clj:5200 clojure.core/load-one
 29:       core.clj:5237 clojure.core/load-lib
 30:     RestFn.java:142 clojure.lang.RestFn.applyTo
 31:        core.clj:602 clojure.core/apply
 32:       core.clj:5271 clojure.core/load-libs
 33:     RestFn.java:137 clojure.lang.RestFn.applyTo
 34:        core.clj:602 clojure.core/apply
 35:       core.clj:5352 clojure.core/require
 36:     RestFn.java:703 clojure.lang.RestFn.invoke
 37:            db.clj:4 datomic.db/loading
 38:    (Unknown Source) datomic.db__init.load
 39:    (Unknown Source) datomic.db__init.<clinit>
 40:    (Unknown Source) java.lang.Class.forName0
 41:      Class.java:247 java.lang.Class.forName
 42:        RT.java:2030 clojure.lang.RT.loadClassForName
 43:         RT.java:417 clojure.lang.RT.load
 44:         RT.java:398 clojure.lang.RT.load
 45:       core.clj:5386 clojure.core/load[fn]
 46:       core.clj:5385 clojure.core/load
 47:     RestFn.java:408 clojure.lang.RestFn.invoke
 48:       core.clj:5200 clojure.core/load-one
 49:       core.clj:5237 clojure.core/load-lib
 50:     RestFn.java:142 clojure.lang.RestFn.applyTo
 51:        core.clj:602 clojure.core/apply
 52:       core.clj:5271 clojure.core/load-libs
 53:     RestFn.java:137 clojure.lang.RestFn.applyTo
 54:        core.clj:602 clojure.core/apply
 55:       core.clj:5352 clojure.core/require
 56:     RestFn.java:703 clojure.lang.RestFn.invoke
 57:         query.clj:4 datomic.query/loading
 58:    (Unknown Source) datomic.query__init.load
 59:    (Unknown Source) datomic.query__init.<clinit>
 60:    (Unknown Source) java.lang.Class.forName0
 61:      Class.java:247 java.lang.Class.forName
 62:        RT.java:2030 clojure.lang.RT.loadClassForName
 63:         RT.java:417 clojure.lang.RT.load
 64:         RT.java:398 clojure.lang.RT.load
 65:       core.clj:5386 clojure.core/load[fn]
 66:       core.clj:5385 clojure.core/load
 67:     RestFn.java:408 clojure.lang.RestFn.invoke
 68:       core.clj:5200 clojure.core/load-one
 69:       core.clj:5237 clojure.core/load-lib
 70:     RestFn.java:142 clojure.lang.RestFn.applyTo
 71:        core.clj:602 clojure.core/apply
 72:       core.clj:5271 clojure.core/load-libs
 73:     RestFn.java:137 clojure.lang.RestFn.applyTo
 74:        core.clj:602 clojure.core/apply
 75:       core.clj:5352 clojure.core/require
 76:     RestFn.java:421 clojure.lang.RestFn.invoke
 77:           api.clj:6 datomic.api/loading
 78:    (Unknown Source) datomic.api__init.load
 79:    (Unknown Source) datomic.api__init.<clinit>
 80:    (Unknown Source) java.lang.Class.forName0
 81:      Class.java:247 java.lang.Class.forName
 82:        RT.java:2030 clojure.lang.RT.loadClassForName
 83:         RT.java:417 clojure.lang.RT.load
 84:         RT.java:398 clojure.lang.RT.load
 85:       core.clj:5386 clojure.core/load[fn]
 86:       core.clj:5385 clojure.core/load
 87:     RestFn.java:408 clojure.lang.RestFn.invoke
 88:       core.clj:5200 clojure.core/load-one
 89:       core.clj:5237 clojure.core/load-lib
 90:     RestFn.java:142 clojure.lang.RestFn.applyTo
 91:        core.clj:602 clojure.core/apply
 92:       core.clj:5271 clojure.core/load-libs
 93:     RestFn.java:137 clojure.lang.RestFn.applyTo
 94:        core.clj:604 clojure.core/apply
 95:       core.clj:5363 clojure.core/use
 96:     RestFn.java:408 clojure.lang.RestFn.invoke
 97:    NO_SOURCE_FILE:1 cljs-template.server/eval1941[fn]
 98:    NO_SOURCE_FILE:1 cljs-template.server/eval1941
 99:  Compiler.java:6465 clojure.lang.Compiler.eval
 100:  Compiler.java:6455 clojure.lang.Compiler.eval
 101:  Compiler.java:6431 clojure.lang.Compiler.eval
 102:       core.clj:2795 clojure.core/eval
 103:        core.clj:532 swank.core/eval782[fn]
 104:    MultiFn.java:163 clojure.lang.MultiFn.invoke
 105:        basic.clj:54 swank.commands.basic/eval-region
 106:        basic.clj:44 swank.commands.basic/eval-region
 107:        basic.clj:73 swank.commands.basic/eval968[fn]
 108:        Var.java:401 clojure.lang.Var.invoke
 109:    (Unknown Source) user/eval1937
 110:  Compiler.java:6465 clojure.lang.Compiler.eval
 111:  Compiler.java:6431 clojure.lang.Compiler.eval
 112:       core.clj:2795 clojure.core/eval
 113:        core.clj:100 swank.core/eval-in-emacs-package
 114:        core.clj:256 swank.core/eval-for-emacs
 115:        Var.java:409 clojure.lang.Var.invoke
 116:        AFn.java:167 clojure.lang.AFn.applyToHelper
 117:        Var.java:518 clojure.lang.Var.applyTo
 118:        core.clj:600 clojure.core/apply
 119:        core.clj:107 swank.core/eval-from-control
 120:        core.clj:330 swank.core/spawn-worker-thread[fn]
 121:        AFn.java:159 clojure.lang.AFn.applyToHelper
 122:        AFn.java:151 clojure.lang.AFn.applyTo
 123:        core.clj:600 clojure.core/apply
 124:        core.clj:326 swank.core/spawn-worker-thread[fn]
 125:     RestFn.java:397 clojure.lang.RestFn.invoke
 126:         AFn.java:24 clojure.lang.AFn.run
 127:     Thread.java:662 java.lang.Thread.run

Saya kemudian tekan 0 untuk menutup stacktrace, dan tekan Ctrl-x Ctrl-e pada panggilan (ns) lagi, sekarang kesalahan saya adalah:

Could not initialize class datomic.api__init
  [Thrown class java.lang.NoClassDefFoundError]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0:    (Unknown Source) java.lang.Class.forName0
  1:      Class.java:247 java.lang.Class.forName
  2:        RT.java:2030 clojure.lang.RT.loadClassForName
  3:         RT.java:417 clojure.lang.RT.load
  4:         RT.java:398 clojure.lang.RT.load
  5:       core.clj:5386 clojure.core/load[fn]
  6:       core.clj:5385 clojure.core/load
  7:     RestFn.java:408 clojure.lang.RestFn.invoke
  8:       core.clj:5200 clojure.core/load-one
  9:       core.clj:5237 clojure.core/load-lib
 10:     RestFn.java:142 clojure.lang.RestFn.applyTo
 11:        core.clj:602 clojure.core/apply
 12:       core.clj:5271 clojure.core/load-libs
 13:     RestFn.java:137 clojure.lang.RestFn.applyTo
 14:        core.clj:604 clojure.core/apply
 15:       core.clj:5363 clojure.core/use
 16:     RestFn.java:408 clojure.lang.RestFn.invoke
 17:    NO_SOURCE_FILE:1 cljs-template.server/eval6292[fn]
 18:    NO_SOURCE_FILE:1 cljs-template.server/eval6292
 19:  Compiler.java:6465 clojure.lang.Compiler.eval
 20:  Compiler.java:6455 clojure.lang.Compiler.eval
 21:  Compiler.java:6431 clojure.lang.Compiler.eval
 22:       core.clj:2795 clojure.core/eval
 23:        core.clj:532 swank.core/eval782[fn]
 24:    MultiFn.java:163 clojure.lang.MultiFn.invoke
 25:        basic.clj:54 swank.commands.basic/eval-region
 26:        basic.clj:44 swank.commands.basic/eval-region
 27:        basic.clj:73 swank.commands.basic/eval968[fn]
 28:        Var.java:401 clojure.lang.Var.invoke
 29:    (Unknown Source) cljs-template.server/eval6288
 30:  Compiler.java:6465 clojure.lang.Compiler.eval
 31:  Compiler.java:6431 clojure.lang.Compiler.eval
 32:       core.clj:2795 clojure.core/eval
 33:        core.clj:100 swank.core/eval-in-emacs-package
 34:        core.clj:256 swank.core/eval-for-emacs
 35:        Var.java:409 clojure.lang.Var.invoke
 36:        AFn.java:167 clojure.lang.AFn.applyToHelper
 37:        Var.java:518 clojure.lang.Var.applyTo
 38:        core.clj:600 clojure.core/apply
 39:        core.clj:107 swank.core/eval-from-control
 40:        core.clj:330 swank.core/spawn-worker-thread[fn]
 41:        AFn.java:159 clojure.lang.AFn.applyToHelper
 42:        AFn.java:151 clojure.lang.AFn.applyTo
 43:        core.clj:600 clojure.core/apply
 44:        core.clj:326 swank.core/spawn-worker-thread[fn]
 45:     RestFn.java:397 clojure.lang.RestFn.invoke
 46:         AFn.java:24 clojure.lang.AFn.run
 47:     Thread.java:662 java.lang.Thread.run

Apa yang saya lakukan salah? Bagaimana cara mendapatkan datomic bekerja di emacs saya menggunakan swank / slime.


4
2018-05-23 18:30


asal


Jawaban:


Ternyata saya mengeksekusi perintah yang salah.

Saya menjalankan lein deps dan mendapatkan kesalahan berikut.

...
Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dversion=0.1.3157 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=com.datomic -DartifactId=datomic -Dversion=0.1.3157 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.apache.maven:super-pom:pom:2.0
    2) com.datomic:datomic:jar:0.1.3157

Saya melihat bahwa file README dalam kode datomic yang diunduh juga mengandung penyebutan menambahkan datomic ke mvn saya. Secara alami (inilah bagian bodohnya) saya berasumsi bahwa mereka mengatakan hal yang sama.

Lein akan memberi tahu Anda bahwa Anda harus mengeksekusi

mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dversion=0.1.3157 -Dpackaging=jar -Dfile=/path/to/file

README mengatakan Anda harus mengeksekusi

mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dfile=datomic-${DATOMIC-VERSION}.jar -DpomFile=pom.xml

Apakah Anda memperhatikan bahwa instruksi README juga menyertakan file pom.xml? Saya juga tidak! Ya, itu penting.

Pokoknya, pastikan juga menyertakan file pom.xml. Jika Anda mencoba menambahkan datomic 0.1.3157 ke repositori mvn Anda, Anda akan menjalankan yang berikut ini di direktori datomik yang Anda unduh.

mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dfile=datomic-0.1.3157.jar -DpomFile=pom.xml

4
2018-05-23 19:41



Saya memposting a proyek kerja di sini

kecurigaan saya yang biasa dalam men-debug masalah berayun adalah:

  • adalah leiningen terkini
  • versi lein-swank
  • versi emacs (Emacs 24, saya temukan jauh lebih andal)
  • sisa dependensi lama dalam direktori lib

EDIT: cara yang benar untuk mendapatkan toples datomik seperti yang dikatakan Stephen Cagle, disalin dari komentarnya di bawah ini:

 mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dfile=datomic-${DATOMIC-VERSION}.jar 

3
2018-05-23 18:59