Clojure unable to resolve symbol in repl - clojure

I'm doing the Exercise 4.12 in Packt Publishing's The Clojure Workshop (source code on Github).
The instructions were to create a deps.edn file and a tennis.clj file and in an REPL (I'm using clj) type the following:
(in-ns 'packt-clj.tennis)
(first-match "match_scores_1991-2016_unindexed_csv.csv")
When I try to call firs-match, whether in ./ ./src/ or ./src/pakt_clj/ I get the error
Unable to resolve symbol: first-match in this context
Any help in getting this to work is much appreciated.

Related

leiningen project: repl-options/init

When I add :repl-options {:init (print "x..")} to ~/.lein/profiles.clj it does what it should on every repl start-up. however, when I add the same to my local project.clj, I receive this error:
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(/tmp/form-init5885833654225579206.clj:1:886)
I'm using leiningen 2.5.3
I've stumbled across this issue as well - I tried to use multiple profiles, each with its own :repl-options.
The issue is that Leiningen doesn't merge `:init: correctly. You can refer to this issue for more details.
Unfortunately, I couldn't find any fix that would work for me. And the issue itself won't be fixed till Leiningen 3.0.

Cannot start a remote ClojureScript bREPL (it says "Unable to resolve symbol...")

ClojureScript noob here.
I'm following the following ClojureScript tutorial using Boot: https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition/tutorial-02.md#browser-repl-brepl
I can follow it and connect a command line/boot repl to my site by running boot repl -c andn then (start-repl), but I'd like to connect to the site using a richer text editor based REPL.
I've downloaded the ProtoRepl for the atom text editor. I can connect to the repl just fine by giving it the repl's host + port, but when I try to run (start-repl) it throws the error:
(start-repl)
=> CompilerException java.lang.RuntimeException: Unable to resolve symbol: start-repl in this context, compiling:(C:\Users\Zain\AppData\Local\Temp\boot.user4327288409706217009.clj:1:1)
It seems like I'm missing some ClojureScript/boot specific imports, but I'm not sure what to add or how to add it.
Here's some additional debugging info:
Running (def start-repl) on the working boot repl connection, vs the failing proto-repl connection:
Boot repl:
cljs.user=> (def start-repl)
#'cljs.user/start-repl
Proto-repl:
(def start-repl)
=>
#'user/start-repl
The start-repl command is provided by the adzerk boot-cljs-repl library. If you're in the cljs.user namespace, the command is going to be:
(adzerk.boot-cljs-repl/start-repl)
If this is your first time entering the bREPL, Proto-REPL is going throw an error on every keystroke. This is Proto-REPL trying and failing to validate/autocomplete your clojure expressions. The quickest way to get rid of these errors is to just disable autocomplete:
Go to Atom's Preferences
click on "Packages"
search for "proto-repl" under "Installed Packages"
click on "Settings" under the "proto-repl" box
scroll down to the "Enable Autocompletion" setting and unclick the checkbox
restart Atom
Run through the steps to start the Brepl again and you should have a decently working browser repl.
It looks like from the tutorial that the start-repl function is in the boot.user namespace. Proto REPL uses the user namespace by default. Try (boot.user/start-repl)

Missing doc in non-user namespaces in Clojure 1.5

What should I do to get doc available again?
brew install --devel leiningen
lein new app yeehaw
cd yeehaw
; edit project.clj and replace "1.4.0" with 1.5.0-RC1"
lein repl
yeehaw.core=> (doc map)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: doc
in this context, compiling:(NO_SOURCE_PATH:1:1)
This change comes from CLJ-1085 and this associated source.
Note that doc and the usual REPL functionality is still available in the user namespace, but it would be nice to have it at my fingertips in my app's namespace, at least while in the REPL.
Get doc into current namespace:
(clojure.core/use '[clojure.repl :only (doc)])
And after that try doc again.
Thanks to help from clojure IRC, here are some options:
use clojure.repl/doc instead of doc
use (apply require clojure.main/repl-requires) to bring doc and other REPL functionality into a new namespace.

Getting slime to find files on classpath, and contrib

I recently decided to start using Slime/Swank for writing Clojure. I installed Incanter, Clojure, Slime and Swank yesterday by following this blogpost to the letter, which worked fine. However, I'm experiencing a problem getting Slime to find directories and files on the classpath. I'm running Slime using lein swank and slime-connect in Aquamacs on OS X 10.6. I have two questions:
1) I set up a small project to build a game of life simulation. I have a file called grid.clj from doing this earlier, which I put in the project's lib directory. In core.clj I put the following
(ns gof.core
(:require grid))
(def w (grid.make_grid 8))
Doing C-x C-e after this piece of code gives this error message in the repl:
Could not locate grid__init.class or grid.clj on classpath:
[Thrown class java.io.FileNotFoundException]
so I looked at my classpath using
(doseq [p (.getURLs (java.lang.ClassLoader/getSystemClassLoader))] (println (.getPath p)))
which produced this:
/Users/zjanes/Documents/gof/test/
/Users/zjanes/Documents/gof/test-resources
/Users/zjanes/Documents/gof/src/
/Users/zjanes/Documents/gof/classes/
/Users/zjanes/Documents/gof/resources
/Users/zjanes/Documents/gof/lib/clojure-1.3.0.jar
/Users/zjanes/Documents/gof/lib/grid.clj
/Users/zjanes/.lein/plugins/swank-clojure-1.3.4.jar
nil
user>
It seems to me that grid.clj is on this classpath, so why am I getting the error message?
2) In trying to solve this I had a look at clojure-1.3.0.jar and couldn't find anything that looks like it comes from clojure.contrib. Is contrib not included when installing clojure as described above?
I'm sure it's obvious I'm a complete novice with clojure, so the clearer the answer, and the less presumed knowledge, the better.
For completeness, I've looked at these answers (1 2 3) and this page, plus some googling around.
Thanks in advance
that tutorial is from 2009 and as far as I can tell it can't be made to work using those instructions.
Clojure contrib has been split up into many sub projects in clojure 1.3 so it no longer exits under that name.
in general clojure namespaces now have two parts, for instance:
(ns gof.core
(:require [incanter.grid])

Which clojure jar contains clojure.contrib.io.Streams?

I am trying to compile some Clojure code to Java using the Clojure 1.2 compiler. I am including the Clojure and Clojure-contrib 1.2 jars in the classpath. When I do the compile it fails and I get the folowing error:
Exception in thread "main" java.lang.ClassNotFoundException: clojure.contrib.io.Streams (io.clj:121)
: Has anyone seen this before?
Update:
Here is the line I use to compile my clj files:
java -cp "..\lib\h2.jar;..\lib\vaadin-6.4.4.jar;..\lib\clojure.jar;..\lib\clojure-contrib.jar;..\lib\wlfullclient-10.3.0.0.jar;..\..\..\..\..\jre1.6windows32bit\lib\rt.jar;." -Dclojure.compile.path=cljclasses clojure.lang.Compile oe.main.oe-main
clojure.contrib.io.Streams is a protocol defined in clojure.contrib.io
To help you more you have to share more details about how and what you are trying to compile.
use (compile 'oe.main.oe-main) from a clojure REPL using the same class path, and this works