clojureleiningencompojuremidje

Hot to fix "WARNING: any? already refers to: #'clojure.core/any? in namespace: leiningen.midje, being replaced by: #'leiningen.midje/any?"


I'm try run tests in leiningen's compojure template (lein new compojure financeiro), using the midje framework and receive a warning:

lein midje
WARNING: any? already refers to: #'clojure.core/any? in namespace: leiningen.midje, being replaced by: #'leiningen.midje/any?
nil
All checks (3) succeeded.

My test code handler_test.clj:

(ns financeiro.handler-test
  (:require
    ; [clojure.test :refer :all]
    [midje.sweet :refer :all]
    [ring.mock.request :as mock]
    [financeiro.handler :refer :all]))

; (deftest test-app
;   (testing "main route"
;     (let [response (app (mock/request :get "/"))]
;       (is (= (:status response) 200))
;       (is (= (:body response) "Hello World"))))

;   (testing "not-found route"
;     (let [response (app (mock/request :get "/invalid"))]
;       (is (= (:status response) 404)))))

(facts "'Hello World' main route"
  (fact "response status is 200"
    (let [response (app (mock/request :get "/"))]
      (:status response)=> 200))

  (fact "body text is 'Hello World'"
    (let [response (app (mock/request :get "/"))]
      (:body response)=> "Hello World")))

(facts "not-found route"
  (fact "response status is 404"
    (let [response(app (mock/request :get "/invalid"))]
      (:status response)=> 404)))

My project file project.clj:

(defproject financeiro "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"]
  ]
  :plugins [
    [lein-ring "0.12.5"]
  ]
  :ring {
    :handler financeiro.handler/app
  }
  :profiles {
    :dev {
      :dependencies [
        [javax.servlet/servlet-api "2.5"]
        [ring/ring-mock "0.3.2"]
        [midje "1.9.8"]
      ]
      :plugins [
        [lein-midje "3.2.1"]
      ]
    }
  }
)

When I run default tests with clojure.test (lein test), I not receive warning, but I when run with midje.sweet (lein midje) I receive the warning about 'namespace: leiningen.midje' and 'replace #'clojure.core/any? to #'leiningen.midje/any?', I searching for solution in the web but I don't find for this especific warning (leiningen/compojure/midje), I'm a beginner in clojure and midje. I'm learning now. In which file I can replace this namespace? There is simple solution to remove this warning? Or this a bug in framework midje?

This does not disturb the execution of the tests, but it is annoying to see this message every time it's run the tests.

Note: I tryied the previous version of midje too [midje "1.9.6"], but unsuccessfully!


Solution

  • This particular issue was solved in this Pull Request.

    For the general case you can get rid of this warning (when it comes from your code) by excluding (= un-refering) the symbol you want to require from another namespace than clojure.core

    Here is an example from a different context:

    Warning

    (ns urbest.apheleia.system.typography
      (:require [garden.units :refer [rem]]))
    
    WARNING: rem already refers to: #'clojure.core/rem in namespace: urbest.apheleia.system.typography, being replaced by: #'garden.units/rem
    

    No more warning

    (ns urbest.apheleia.system.typography
      (:refer-clojure :exclude [rem])
      (:require [garden.units :refer [rem]]))