Where should the file user.clj go?
Asked Answered
T

3

6

I am trying to setup proto-repl atom-editor package and apparently it needs a file user.clj to exist somewhere - which I guess is some leiningen's init file.

Where should I create this file?

Teeters answered 26/3, 2016 at 12:17 Comment(3)
user.clj, if present, defines the default clojure namespace. Leiningen's init file is project.clj.Friedly
What leads you to think that user.clj is needed?Galvanic
A nasty error on the proto repl complaining about it's unexistence.Teeters
F
8

Clojure will load the file user.clj from your class path if it is found. In a default leinengen project src/ will be on the class path, so if you create src/user.clj the contents of that file will be loaded in the context of the user namespace.

user is the default namespace for the clojure repl, but some leiningen projects override this. In order to access definitions in user.clj you will need to either pull user into scope (using require or use) or make sure that user is your starting namespace.

Friedly answered 26/3, 2016 at 18:35 Comment(3)
I'm wondering why this was downvoted. user.clj is loaded based on the classpath, the first user.clj that is found will be loaded to define the user namespace. The information here might not be sufficient for explaining proto-repl, but user.clj is a clojure feature, not a leiningen or proto-repl one.Friedly
Because it's a real clj file in the project, not the user.clj for leiningen... :DKisner
user.clj is a real file, it's loaded by clojure, not leinengen or anything elseFriedly
B
2

See the Proto REPL demo project https://github.com/jasongilman/proto-repl-demo/blob/master/dev/user.clj for an example of how to setup user.clj You should also add a dependency on clojure.tools.namespace in the project.clj https://github.com/jasongilman/proto-repl-demo/blob/master/project.clj

I just pushed some changes to Proto REPL last night to improve this area but you'll still benefit from having one setup.

Bronnie answered 26/3, 2016 at 20:13 Comment(0)
F
1

According to the proto-repl page, it might use some functions from user namespace when reloading code in REPL (reset function) but it shouldn't be required.

You might want to take a look at the proto-repl demo project to see the more advanced setup.

Fey answered 26/3, 2016 at 19:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.