# Error: "No such namespace: mc" (monger, monger.collection)

**URL:** https://clojureverse.org/t/error-no-such-namespace-mc-monger-monger-collection/8977
**Category:** Troubleshooting
**Tags:** clojure, databases, leiningen
**Created:** [May 23, 2022, 4:33pm UTC](https://clojureverse.org/t/error-no-such-namespace-mc-monger-monger-collection/8977 "2022-05-23T16:33:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![2FO](https://clojureverse.org/letter_avatar_proxy/v4/letter/2/87869e/32.png) [@2FO](https://clojureverse.org/u/2FO)
#### Post date: [May 23, 2022, 4:33pm UTC](https://clojureverse.org/t/error-no-such-namespace-mc-monger-monger-collection/8977/1 "2022-05-23T16:33:28Z")

</div>

I’m running into a namespace error. When I attempt to query a collection from the `cljblog.db` namespace.

cljblog/db.clj:

```auto

(ns cljblog.db
  (:require [monger.core :as mg]
            [monger.collection :as mc]))

(def db (-> "mongodb://127.0.0.1/cljblog-test"
            mg/connect-via-uri
            :db))

```

Steps taken:

1. start repl  
`lein repl`

2. switch namespace

`(in-ns 'cljblog.db)`

1. Query the collection

`(mc/find-maps db "articles")`

Full error message:

```auto
 Syntax error compiling at (form-init17588852473615642213.clj:1:1).
No such namespace: mc 

```

My project.clj

```auto
(defproject cljblog "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]
                 [com.novemberain/monger "3.1.0"]]
  :plugins [[lein-ring "0.12.5"]]
  :ring {:handler cljblog.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})

```

The repl was restarted after the addition of each dependency.  
I get the same error with the latest monger version (`3.5.0`)

mongodb is installed and running on the system.

---

<div class="post-metadata">

### Author: ![p-himik](https://clojureverse.org/user_avatar/clojureverse.org/p-himik/32/4137_2.png) [@p-himik](https://clojureverse.org/u/p-himik)
#### Post date: [May 23, 2022, 5:05pm UTC](https://clojureverse.org/t/error-no-such-namespace-mc-monger-monger-collection/8977/2 "2022-05-23T17:05:17Z")

</div>

`in-ns` doesn’t load the namespace, it just changes the current namespace. So that `ns` form with all its contents, along with all the `def`s and whatnot in that namespace - it’s all ignored.

One way to fix it would be to add `(require 'cljblog.db)` before that call to `in-ns`. The other way would be to figure out how to properly load files in Lein REPL. I don’t use Lein myself so I don’t know.

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [November 22, 2022, 5:06am UTC](https://clojureverse.org/t/error-no-such-namespace-mc-monger-monger-collection/8977/3 "2022-11-22T05:06:14Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
