technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

"lein repl" get "Unable to resolve symbol: create in this context" error #2714

Closed KUR-creative closed 3 years ago

KUR-creative commented 3 years ago

Initial debugging steps Before creating a report, especially around exceptions being thrown when running Leiningen, please check if the error still occurs after:

Describe the bug I created a fresh project via lein new app spec-test-cider. I edited the source of src/spec_test_cider/core.clj to require things from test.check, added test.check dependency to project.clj. Then in spec-test-cider directory, when I started a repl, following error occurs.

$ lein repl
Syntax error compiling at (/tmp/form-init4567756205328692889.clj:4353:33).
Unable to resolve symbol: create in this context

Full report at:
/tmp/clojure-938119805586141248.edn
Subprocess failed (exit code: 1)

After a while, it prints REPL server launch timed out. and exit. After the above error occurs, lein keep getting the error even if I make the source completely empty or make project.clj default.

To Reproduce Steps to reproduce the behavior:

  1. Run lein new app spec-test-cider
  2. Edit src/spec_test_cider/core.clj and project.clj
  3. Run lein repl

Actual behavior lein repl failed with slightly modified source file and project.clj. After that, it continues to occur even with the default project.clj and empty source file.

Expected behavior Just start repl

Link to sample project src/spec_test_cider/core.clj

(ns clj-test-expr.core
  (:require [clojure.test.check :as tc]
            [clojure.test.check.generators :as gen]
            [clojure.test.check.properties :as prop]
            [clojure.pprint :as pp]
            )
  (:gen-class))

;;==============================================================
(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (println "Hello, World!"))

project.clj

(defproject spec-test-cider "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "https://www.eclipse.org/legal/epl-2.0/"}
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [org.clojure/test.check "1.1.0"]
                 ]
  :main ^:skip-aot spec-test-cider.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all
                       :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})

Logs full report:

$ cat /tmp/clojure-938119805586141248.edn
{:clojure.main/message
 "Syntax error compiling at (/tmp/form-init4567756205328692889.clj:4353:33).\nUnable to resolve symbol: create in this context\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 4353,
  :clojure.error/column 33,
  :clojure.error/source "form-init4567756205328692889.clj",
  :clojure.error/path "/tmp/form-init4567756205328692889.clj",
  :clojure.error/class java.lang.RuntimeException,
  :clojure.error/cause
  "Unable to resolve symbol: create in this context"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (/tmp/form-init4567756205328692889.clj:4353:33).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 4353,
     :clojure.error/column 33,
     :clojure.error/source "/tmp/form-init4567756205328692889.clj"},
    :at [clojure.lang.Compiler analyze "Compiler.java" 6808]}
   {:type java.lang.RuntimeException,
    :message "Unable to resolve symbol: create in this context",
    :at [clojure.lang.Util runtimeException "Util.java" 221]}],
  :trace
  [[clojure.lang.Util runtimeException "Util.java" 221]
   [clojure.lang.Compiler resolveIn "Compiler.java" 7414]
   [clojure.lang.Compiler resolve "Compiler.java" 7358]
   [clojure.lang.Compiler analyzeSymbol "Compiler.java" 7319]
   [clojure.lang.Compiler analyze "Compiler.java" 6768]
   [clojure.lang.Compiler analyze "Compiler.java" 6745]
   [clojure.lang.Compiler$HostExpr$Parser parse "Compiler.java" 1020]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7107]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7095]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler access$300 "Compiler.java" 38]
   [clojure.lang.Compiler$LetExpr$Parser parse "Compiler.java" 6384]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7107]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7095]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7095]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler analyze "Compiler.java" 6745]
   [clojure.lang.Compiler$InvokeExpr parse "Compiler.java" 3888]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7109]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler analyze "Compiler.java" 6745]
   [clojure.lang.Compiler$InvokeExpr parse "Compiler.java" 3888]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7109]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler access$300 "Compiler.java" 38]
   [clojure.lang.Compiler$LetExpr$Parser parse "Compiler.java" 6384]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7107]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler analyze "Compiler.java" 6745]
   [clojure.lang.Compiler$BodyExpr$Parser parse "Compiler.java" 6120]
   [clojure.lang.Compiler$FnMethod parse "Compiler.java" 5467]
   [clojure.lang.Compiler$FnExpr parse "Compiler.java" 4029]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7105]
   [clojure.lang.Compiler analyze "Compiler.java" 6789]
   [clojure.lang.Compiler eval "Compiler.java" 7174]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.Compiler loadFile "Compiler.java" 7574]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [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 "Unable to resolve symbol: create in this context",
  :phase :compile-syntax-check}}

Environment

Additional context Add any other context you have about the problem here. Did this work previously on older versions of Leiningen, or older JDK's?

technomancy commented 3 years ago

I can't reproduce this problem. It could be due to some plugins you have configured on your machine maybe?

technomancy commented 3 years ago

Feel free to reopen this if you can come up with a repro case that doesn't involve any 3rd-party code.

hagenek commented 3 years ago

Same error: Syntax error compiling at (/private/var/folders/4x/kcnw7mpn7cscc84llq9rz5gr0000gn/T/form-init5070701951296281096.clj:4353:33). Unable to resolve symbol: create in this context

Leiningen version: Leiningen 2.9.6 on Java 16.0.2 OpenJDK 64-Bit Server VM Happens when I try to open a REPL with this dependencies in project.clj: [org.clojure/clojure "1.10.1"] [com.walmartlabs/lacinia "0.38.0"]]

Rovanion commented 3 years ago

Just had the same issue with a project.clj like

(defproject tove "0.1.0"
  :dependencies [[org.clojure/clojure "1.10.3"]] ; The language itself.
  :main ^:skip-aot tove.core  ; In order to prevent staticization of dynamic things like environment variable lookup.
  )

and a single source file src/tove/core.clj like

(ns tove.main)

(defn -main [] "Hello world!")

The problem in my case was with the namespace declared at the top of that file. If I change it to tove.core lein repl will work just as expected. With the namespace being tove.main I get the following error.

Syntax error compiling at (/tmp/form-init6924841063651840338.clj:4341:33).
Unable to resolve symbol: create in this context

Full report at:
/tmp/clojure-15744339133944682647.edn
Subprocess failed

and the full report reading

{:clojure.main/message
 "Syntax error compiling at (/tmp/form-init6924841063651840338.clj:4341:33).\nUnable to resolve symbol: create in this context\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 4341,
  :clojure.error/column 33,
  :clojure.error/source "form-init6924841063651840338.clj",
  :clojure.error/path "/tmp/form-init6924841063651840338.clj",
  :clojure.error/class java.lang.RuntimeException,
  :clojure.error/cause
  "Unable to resolve symbol: create in this context"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (/tmp/form-init6924841063651840338.clj:4341:33).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 4341,
     :clojure.error/column 33,
     :clojure.error/source "/tmp/form-init6924841063651840338.clj"},
    :at [clojure.lang.Compiler analyze "Compiler.java" 6812]}
   {:type java.lang.RuntimeException,
    :message "Unable to resolve symbol: create in this context",
    :at [clojure.lang.Util runtimeException "Util.java" 221]}],
  :trace
  [[clojure.lang.Util runtimeException "Util.java" 221]
   [clojure.lang.Compiler resolveIn "Compiler.java" 7418]
   [clojure.lang.Compiler resolve "Compiler.java" 7362]
   [clojure.lang.Compiler analyzeSymbol "Compiler.java" 7323]
   [clojure.lang.Compiler analyze "Compiler.java" 6772]
   [clojure.lang.Compiler analyze "Compiler.java" 6749]
   [clojure.lang.Compiler$HostExpr$Parser parse "Compiler.java" 1020]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7111]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7099]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler access$300 "Compiler.java" 38]
   [clojure.lang.Compiler$LetExpr$Parser parse "Compiler.java" 6388]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7111]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7099]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7099]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler analyze "Compiler.java" 6749]
   [clojure.lang.Compiler$InvokeExpr parse "Compiler.java" 3892]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7113]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler analyze "Compiler.java" 6749]
   [clojure.lang.Compiler$InvokeExpr parse "Compiler.java" 3892]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7113]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler access$300 "Compiler.java" 38]
   [clojure.lang.Compiler$LetExpr$Parser parse "Compiler.java" 6388]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7111]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler analyze "Compiler.java" 6749]
   [clojure.lang.Compiler$BodyExpr$Parser parse "Compiler.java" 6124]
   [clojure.lang.Compiler$FnMethod parse "Compiler.java" 5471]
   [clojure.lang.Compiler$FnExpr parse "Compiler.java" 4033]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7109]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler eval "Compiler.java" 7178]
   [clojure.lang.Compiler eval "Compiler.java" 7171]
   [clojure.lang.Compiler eval "Compiler.java" 7171]
   [clojure.lang.Compiler eval "Compiler.java" 7171]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.Compiler loadFile "Compiler.java" 7578]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [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 "Unable to resolve symbol: create in this context",
  :phase :compile-syntax-check}}

So the issue is probably user generated, but I think we can blame either Clojure or Leiningen for the abysmal error reporting.