Showing posts with label Clojure. Show all posts
Showing posts with label Clojure. Show all posts

Wednesday, September 11, 2013

Install libraries into Clojure

This can be a bit confusing at the beginning, the loading of libraries into the Clojure project.
For this I use Eclipse and the excellent CounterClockwise.

The initial dependencies can be found in the Leiningen dependencies folder, shown below.




This is the initial project.clj file with one single dependency.



Adding the dependencies to the project.clj file


Doing the above will make Lein go and get the libs and place them in the dependencies folder as shown.




Not using Eclipse?

If Lein is installed, you can navigate to the project folder in the command line, terminal, and enter:
lein deps




Friday, September 6, 2013

Can't get (use 'clojure.repl) to work in Clojure

Clojure 1.5.1
In the REPL you might not be able to use the clojure.repl library.

Normally you would type:
(use 'clojure.repl)

However this causes a problem. You need to Require it first.

So type,
(require 'clojure.repl)

then,
(use 'clojure.repl)

Saturday, February 4, 2012

vsClojure - .cljproj is not supported by this version.

For a .NET developer, when starting out with Clojure it seems obvious to try to get it to work in Visual Studio rather than struggle with Emacs and Slime. So you visit the the Extension Manager, search for Clojure, and instal the extension.

If you then create a New Project, and select a Clojure project, this message can appear:


'<somestuff>\VisualStudio\10.0\Extensions\vsClojure\2.0.0\Templates\Projects\Clojure\Clojure.cljproj' cannot be opened because its project type (.cljproj) is not supported by this version of the application.
To open it, please use a version that supports this type of project.

So it seems that Visual Studio didn't know about the project type, the .cljproj. 

First attempt to fix vsClojure Failed
I tried something that was suggested in a posting somewhere.

Reset the Skip Package flags. 
This didn't work for me, but may work for you.
You locate Devenv.exe and run in the command line.
Devenv can usually be found at: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
run Devenv.exe /ResetSkipPkgs


The Workaround
I noticed that the DLL was at:
C:\Users\John\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\vsClojure\vsClojure\2.0.0\Runtimes\\1.3.0\Clojure.dll
but the problem wasn't the loading of the DLL, it was the loading of the project with a name. cljpro.

So I thought of starting the REPL to see if that did something. Probably written in C# so it might register something somewhere.

So I ran:
 Clojure.Main.exe


This was found in the same folder as the Clojure dll.
C:\Users\John\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\vsClojure\vsClojure\2.0.0\Runtimes\\1.3.0\Clojure.Main.exe
I then tried to create the Clojure project in Visual Studio and it worked.