1

I'm currently working through "Clojure Data Analysis Cookbook" by Eric Rochester and have encountered an issue with namespace conflicts involving the abs function. I set up my project using Leiningen and included dependencies for incanter (version 1.9.3). However, when I try to require the incanter.core and incanter.io namespaces in my REPL, I get a series of warnings about the abs function being redefined.

Here's what I did:

  1. Created a new project with lein new data-eric.

  2. Added Incanter dependencies to project.clj:

    [incanter/incanter-core "1.9.3"] [incanter/incanter-io "1.9.3"]

Started a REPL in VS Code command + shift + P: Start a Project REPL and Connect -> Leiningen and ran the following commands:

(require '[incanter.core :as ic]
         '[incanter.io :as io])

This resulted in multiple warnings, all related to the abs function being redefined in various namespaces, such as clojure.core.matrix.impl.mathsops, clojure.core.matrix.protocols, and incanter.core.

Example Warning:

WARNING: abs already refers to: #'clojure.core/abs in namespace: clojure.core.matrix.impl.mathsops, being replaced by: #'clojure.core.matrix.impl.mathsops/abs

I understand that this is due to the abs function existing in multiple namespaces, but I'm unsure about the best way to handle these warnings. Should I be concerned about these warnings affecting the functionality of my project? Is there a recommended approach to resolve or work around this issue?

Any guidance or suggestions would be greatly appreciated. Thank you in advance!

1

1 Answer 1

3

Those warnings aren't for you, exactly - they're for the authors of clojure.core.matrix.impl.mathsops, and as far as the compiler knows, that might be you. core.matrix was updated to address these warnings a year and a half ago, but that doesn't exactly help you: Incanter is old and hasn't been updated at all in the last five years, so it's depending on an old version of core.matrix. I would ignore these error messages: if you are really keen you could probably find a way to depend on a newer version of core.matrix while still using the old Incanter, but the version skew would come with its own risks.

4
  • Are there any Incanter alternatives? Nov 16 at 9:55
  • There don’t really need to be; Clojure libraries tend to get to a good working point and stay stable. You could request the author update its dependencies to eliminate these warnings. I was able to do that for some libraries that my own projects use. Nov 16 at 16:50
  • But the reason people are telling you that you can also just ignore the warnings is because you can just ignore the warnings. They don’t suggest anything is likely to break. The code is designed to use the version of abs that is present in that namespace, and it doesn’t matter that Clojure offers its own version now. Nov 16 at 16:51
  • @user3523406 ask in #data-science of Clojurians Slack. Nov 22 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.