Search code examples
clojureleiningenlighttable

How do I add a library to LightTable so that when I use instarepl it will always have said library?


I'd like to add certain library dependencies to LightTable as a whole so that when I am messing around learning new stuff, I don't have to create a new project as a whole.

Let's say I want to always have access to these libraries: math.combinatorics and math.numeric-tower.

Lighttable seems to be calling a repl from leinigen, so am I really needing to add something there?

See https://github.com/LightTable/LightTable/blob/master/project.clj


Solution

  • It will be calling a repl of Leiningen. Rather than adding the dependencies to LightTable you could add them to your Leiningen Profile (~/.lein/profiles.clj) The file would probably look something like this with your dependencies:

    {:user {:dependencies [[math.combinatorics "x.x.x"]
                           [math.numeric-tower "x.x.x"]]}}
    

    Generally this is not a very good idea. It will be a global thing and will probably cause you problems in the future. If you create an application you might find that these two libraries are available when they won't be for other people or on difference computers.

    What would be a better option would be to create a new project using Leiningen. You can then edit your project.clj file to look something like this

    (defproject math-thing "0.1.0-SNAPSHOT"
       :description "FIXME: write description"
       :dependencies [[org.clojure/clojure "1.6.0"]
                      [math.combinatorics  "x.x.x"]
                      [math.numeric-tower  "x.x.x"]])
    

    Then when editing your clj file LightTable uses your project.clj file to start instrepl and will resolve any needed dependencies.