I'm new to Common Lisp, I'm using Emacs/SLIME on Windows 10, and I'm trying to wrap my head around how CL and ASDF/packaging works.
I have a custom package 'my-pack' in a directory 'D:\Dropbox\my-packages'.
I have created a .conf file in:
%LOCALAPPDATA%\config\common-lisp\source-registry.conf.d\
And added this line:
(:tree "D:\\Dropbox\\my-packages\\")
I opened Emacs, started SLIME and made the project via the REPL:
(cl-project:make-project #p"D:/Dropbox/my-packages/my-pack)
I verified that the project is in the directory and then loaded the system with asdf (version 3.3.1):
(asdf:load-system :my-pack)
And it worked fine.
But when I quit and restart Emacs, I get the following error when trying to the load the system:
Component :MY-PACK not found
[Condition of type ASDF/FIND-COMPONENT:MISSING-COMPONENT]
As far as I can tell I've followed the steps in the manual. Any help appreciated.
cl-project's make-project ends with this line:
(push dir asdf:*central-registry*)
it adds your new project's directory to this list that tells ASDF where to look for projects. What is its value when you restart CL?
2.
\config\common-lisp\
Shouldn't it be .config?
However, I don't encourage to use this conf file with :tree. The doc says:
tell ASDF to recursively scan all the subdirectories
So, imagine that just once, you try yourself at web development and you install, for example, JavaScript dependencies with npm or equivalent, you'll end up with a gigantic node_modules/ and your Lisp will now take a few seconds to start up.
I suggest to put your projects under ~/common-lisp/ or ~/quicklisp/local-projects, or to create symlinks, or to add yourself your projects in asdf:*central-registry* from your Lisp startup file:
;; .sbclrc
(pushnew "/home/me/projects/ciel/" asdf:*central-registry* :test #'equal)
Related
I'm trying to install lisp in my laptop by following the instruction command and steps that is suggested this site : https://grishagin.com/lisp/windows10/2017/01/26/install-lisp-Windows10.html.
I have done following steps :
I've extract emacs in my specified directory and add it's bin path to the system variable
PATH
I've created a another new directory named C:\HOME and add it system variable with variable HOME and
value C:\HOME
Clisp 2.48 is installed in my lisp directory and To fix some problem, copied svm.dll out of clisp-
2.48/libsvm directory into clisp-2.48/full.
Place quicklisp.lisp into lisp directory and run following code in clisp
(load "C:/lisp/quicklisp.lisp"),
(quicklisp-quickstart:install :path "C:/lisp/quicklisp/")
this two command worked but when i go from next command : (ql:add-to-init-file)
It shows this error :- READ from #<INPUT CONCATENATED-STREAM # #>: there is no package
with name "QL".
Can anyone please help to solve this error and explain how does this all help for lisp to keep working?
So, in the QuickLisp installation instructions, it says:
(quicklisp-quickstart:install)
But you include an optional parameter :path "C:/lisp/quicklisp/"
Try it again, without the optional parameter, and see if that works better.
I tried to install Lisplab with asdf and quicklisp but they all turned out to fail.
I use sbcl and slime.
Anyone can help me with installation. And I just want to manipulate matrix within lisp:)
Thanks, lisper!
The first thing to do about installing a lisp library using quicklisp, is see if it is available via quicklisp:
(Note for this answer I'm using the configuration roswell slime sbcl on antergos)
CL-USER> (ql:system-apropos "lisplab")
; No value
In this case the project it is not included, you can update your quicklisp, but in this case it is not necessary. this project is not in quicklisp and maybe will not be in the future. then you can choose to continue installing it or search for an atertnative for this thake a look a quickdocs this is a search about math
Let's try to install this quicklisp says this:
Can I load a local project that isn't part of Quicklisp? Yes. The
easiest way is to put the project's directory in Quicklisp's
local-projects directory. For example:
$ cd ~/quicklisp/local-projects/
$ git clone git://github.com/xach/format-time.git
The project will then be loadable via (ql:quickload "format-time")
Also, any system file that can be found via ASDF's source registry
system can be loaded with ql:quickload.
For example, if you have a system file my-project.asd in
/projects/my-project/, you can do something like this:
(push #p"/projects/my-project/" asdf:*central-registry*)
(ql:quickload "my-project")
If my-project depends on systems that are available via Quicklisp that
are not already installed, they will be automatically installed.
so for this project I will download the tarball and extract or download the repository in the local-projects folder, like it is suggested in a comment. In my case is ./roswell/local-projects but in your case should be cd ~/quicklisp/local-projects/
After that you "can" load with quicklisp, but I believe that since this library is not maintained, it will have errors,
If you want to manipulate matrix with lisp I recommend you to use lisp-matrix be sure to have installed lapack in your computer and read the documentaaion carefully especcilay the code at the end of the readme and also the tests.
CL-USER> (ql:quickload :lisp-matrix)
To load "lisp-matrix":
Load 1 ASDF system:
lisp-matrix
; Loading "lisp-matrix"
(:LISP-MATRIX)
CL-USER> (in-package :lisp-matrix-user)
#<PACKAGE "LISP-MATRIX-USER">
LISP-MATRIX-USER> (M* (ones 2 2 :implementation :lisp-array)
(ones 2 2 :implementation :lisp-array))
#<LA-SIMPLE-MATRIX-DOUBLE 2 x 2
2.0d0 2.0d0
2.0d0 2.0d0>
(be aware that foreign-array doesn't work for integers)
I have tried this example ECL repository asdf example , it works fine but it doesn't have any asdf dependencies. If i add
:depends-on (#:inferior-shell)
to example.asd then running the compiled standalone executable gives this error:
Condition of type: SIMPLE-PACKAGE-ERROR
There exists no package with name "ASDF/DRIVER"
No restarts available.
What causes this error, and what is the idiomatic way of dealing with asdf dependencies on ECL ?
EDIT: this problem is fixed for ECL newer than 16.1.3 (fixed in develop branch), so no `require' trick should be needed in the upcoming release.
In general path you have taken is correct.
Make sure, that you have required the ASDF:
(require 'asdf)
(find-package "ASDF/DRIVER")
Then "ASDF/DRIVER" package is defined. On the other hand inferior-shell requires a few other libraries (alexandria for instance), so you have to put the path to them in the ASDF central registry or use the Quicklisp bundles.
More detailed info about building with ECL is available in its Documentation.
// EDIT
After investigation it appears that ASDF has to be manually required at the program start. It is probably a bug. As a workaround add
:prologue-code '(require 'asdf)
to the (asdf:make-build …) for standalone executable. Everything works fine then.
In emacs cider repl, now I know how to use clojure.tools.namespace in a leiningen project. However, when I use it on a single clj file which doesn't belong to any project, it seems clojure.tools.namespace doesn't work on the file:
=> #<FileNotFoundException java.io.FileNotFoundException: Could not locate com/foo__init.class or com/foo.clj on classpath: >
I have declared clojure.tools.namespace in .lein/profile.clj and require it in the clj file. How should I make clojure.tools.namespace work on a single clj file?
My profile.clj
{:user
{:repl-options {:timeout 128000}
:plugins [;; REPL
[cider/cider-nrepl "0.9.0-SNAPSHOT"]
[refactor-nrepl "0.2.2"]
;; Application server
[lein-immutant "2.0.0-SNAPSHOT"]
;; Automated testing
[lein-cloverage "1.0.2"]
[lein-test-out "0.3.1"]
;; Package management
[lein-ancient "0.6.2"]
[lein-clojars "0.9.1"]
;; Documentation
[codox "0.6.8"]
[lein-clojuredocs "1.0.2"]
;; Static analysis
[lein-typed "0.3.4"]
;; [jonase/eastwood "0.1.2"]
[lein-bikeshed "0.1.6"]
[lein-kibit "0.0.8"]]
:jvm-opts ["-Dapple.awt.UIElement=true"]
:dependencies [[org.clojars.gjahad/debug-repl "0.3.3"]
[difform "1.1.2"]
[spyscope "0.1.4"]
[org.clojure/tools.trace "0.7.8"]
[org.clojure/tools.namespace "0.2.9"]
[im.chit/vinyasa "0.2.0"]
[slamhound "1.5.5"]
[criterium "0.4.3"]]
:injections [(require 'spyscope.core)
(require 'alex-and-georges.debug-repl)
(require 'com.georgejahad.difform)
(require '[vinyasa.inject :as inj])
(inj/inject 'clojure.core '>
'[[clojure.repl apropos dir doc find-doc pst source]
[clojure.tools.trace trace trace-forms trace-ns trace-vars
untrace-ns untrace-vars]
[clojure.test run-tests run-all-tests]
[clojure.pprint pprint pp]
[com.georgejahad.difform difform]
[alex-and-georges.debug-repl debug-repl]
[vinyasa.pull pull]])]}}
While this doesn't answer your specific question, it might provide some ideas on
alternative workflows which may help.
lein-exec This is a lein plugin that
lets you write clojure scripts or evaluate clojure expressions on the command line
in a similar way to what can be done with shells, python, ruby, perl etc. Of
course, startup time is a bit high, but this plugin will help you deal with
dependencies etc inside your single clj script file. (there are other possible
solutions to improve the startup speed). See this blog post for some examples
http://charsequence.blogspot.in/2012/04/scripting-clojure-with-leiningen-2.html
A scratch project. I have a fairly generic project called scratch. It just allows
me to create a new file within the src directory of the project which I can use for
experiments or demonstrations. For example, I have a file called stackoverflow.clj
within this scratch project which I use when working out the answer to a clojure
question on stack overflow. In fact, I have a lot of individual clj files in this
directory, each just representing a simple idea, test, experiment etc. It isn't
really a project i.e. I couldn't do a lein run at the root of the project and
expect anything meaningful. However, I can go to the source directory in emacs,
open a file and then run cider.
I'm trying to use functions from other jar files.
Creation of local jar file
I downloaded sample sources from the book Programming Clojure 2nd Ed, and created a jar file with lein jar command.
Use the local jar file
From the hints in this post, I copied the jar file in lib/ directory, then I could add
:resource-paths ["lib/programming-clojure-1.3.0.jar"] in the project.clj.
Test in REPL
With lein classpath command, I could check that the jar file is in class path.
With lein repl, I could use the functions in the jar file.
mire=> (require '[examples.introduction :as e])
nil
mire=> (take 10 examples.introduction/fibs)
(0 1 1 2 3 5 8 13 21 34)
Isses with emacs/cider
I created a t.clj source in the src/ directory, launched emacs with emacs src/t.clj &, and started REPL with M-x cider-jack-in.
I wrote this code, and executed it with C-x C-e.
(ns t
(:require '[examples/introduction :as ex]))
However, I got a message that the file is not found.
java.io.FileNotFoundException: Could not locate introduction__init.class or introduction.clj on
classpath:
What might be wrong?
The namespace is examples.introduction. Also, you don't need to quote the vector inside the ns macro. Try:
(ns t
(:require [examples.introduction :as ex]))
See some examples of use for the ns macro here.
Also, it's customary to have at least two segments in namespaces. Yours could be mynamespace.t for example.