Missing Import Errors in Clojure
Clojure's namespace system uses require, use, and import for different purposes. Getting them mixed up leads to confusing "Unable to resolve symbol" errors.
Clojure Namespace Requires
;; BAD — function not found
(ns my-app.core)
(json/write-str {:a 1}) ;; Unable to resolve symbol: json
;; GOOD — require with alias
(ns my-app.core
(:require [clojure.data.json :as json]))
(json/write-str {:a 1})Java Class Imports
For Java interop, use :import:
;; BAD
(ns my-app.core
(:require [java.time.LocalDateTime])) ;; Wrong!
;; GOOD
(ns my-app.core
(:import [java.time LocalDateTime Instant]
[java.util UUID]))
(LocalDateTime/now)
(UUID/randomUUID)Require vs Use
;; :use imports everything (avoid in modern Clojure)
(ns my-app.core
(:use clojure.string)) ;; Pollutes namespace
;; :require with :refer is preferred
(ns my-app.core
(:require [clojure.string :refer [join split trim]]))Circular Dependencies
Clojure doesn't allow circular namespace dependencies. If A requires B and B requires A:
;; Create a shared namespace C that both A and B can require
;; Or use protocols/multimethods to break the cycle
(ns my-app.protocols)
(defprotocol Processable
(process [this]))
;; Both A and B implement Processable without requiring each otherBugsly captures runtime "Unable to resolve symbol" errors in Clojure applications with the namespace context, helping you quickly identify which import is missing.
Try Bugsly Free
AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.
Get Started FreeRelated Articles
Fix Load Balancer Error in Java
Fix Java application errors behind load balancers including Spring Boot proxy configuration, session affinity, and timeout tuning.
Read moreHow to Fix Generator Error in Node.js
Learn how to fix the Generator Error in Node.js. Step-by-step guide with code examples.
Read moreFix Load Balancer Error in Ruby
Resolve load balancer issues for Ruby web apps using Sinatra, Rack, or Puma, covering proxy headers and connection keep-alive settings.
Read moreFix Connection Refused Error in Remix
Learn how to fix the Connection Refused error in Remix. Step-by-step guide with code examples and solutions. Quick, practical guide for developers.
Read more