I would like to learn some Clojure, and I'm trying to run REPL from Emacs, but I cannot get it to work.
I have created a basic project with lein. I open the generated file core.clj in Emacs, and when I try to run the REPL from it (by running the cider-jack-in), I just get the message:
Symbol's function definition is void: nil
I have toggled the debug-on-error, and the backtrace (several last lines) is:
Debugger entered--Lisp error: (void-function nil)
nil(#<buffer core.clj>)
#[257 " !\203\207\300\207" [exclude predicate] 3 "\n\n(fn ELT)"](#<buffer core.clj>)
seq-map(#[257 " !\203\207\300\207" [exclude predicate] 3 "\n\n(fn ELT)"] (#<buffer core.clj> #<buffer *Minibuf-1*> #<buffer *Warnings*> #<buffer *GNU Emacs*> #<buffer *scratch*> #<buffer *Minibuf-0*> #<buffer *Messages*> #<buffer *code-conversion-work*> #<buffer *Echo Area 0*> #<buffer *Echo Area 1*>))
seq-filter(#[257 "r\211q\210\300\301!)\207" [derived-mode-p cider-repl-mode] 3 "\n\n(fn BUFFER)"] (#<buffer core.clj> #<buffer *Minibuf-1*> #<buffer *Warnings*> #<buffer *GNU Emacs*> #<buffer *scratch*> #<buffer *Minibuf-0*> #<buffer *Messages*> #<buffer *code-conversion-work*> #<buffer *Echo Area 0*> #<buffer *Echo Area 1*>))
cider-repl-buffers()
cider-find-reusable-repl-buffer(nil "~/Development/languages/clojure/playground/test1/")
cider-jack-in(nil)
When I run lein run in the terminal, the code runs properly.
Also, when I run lein repl in the terminal, the REPL runs properly with the following info:
nREPL server started on port 62741 on host 127.0.0.1 - nrepl://127.0.0.1:62741
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14
Lein has Cider version 0.14.0, while Emacs has downloaded version 0.15.0.
Could anyone help me figure out which part of the setup I'm missing, or what I'm doing wrong?
Thanks for the help!
EDIT: Bellow is the contents of Emacs init file, with comments removed:
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
'("tromey" . "http://tromey.com/elpa/") t)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar ido-cur-item nil)
(defvar ido-default-item nil)
(defvar ido-cur-list nil)
(defvar predicate nil)
(defvar inherit-input-method nil)
(defvar my-packages
'(paredit
clojure-mode
clojure-mode-extra-font-locking
cider
ido-ubiquitous
smex
projectile
rainbow-delimiters
tagedit
magit))
(if (eq system-type 'darwin)
(add-to-list 'my-packages 'exec-path-from-shell))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
(add-to-list 'load-path "~/.emacs.d/vendor")
(add-to-list 'load-path "~/.emacs.d/customizations")
(load "shell-integration.el")
(load "navigation.el")
(load "ui.el")
(load "editing.el")
(load "misc.el")
(load "elisp-editing.el")
(load "setup-clojure.el")
(load "setup-js.el")
here's my lein debugging checklist:
remove any meniton of cider-nrepl from ~/.lein/profiles.clj
run lein repl from a terminal, then cider-connect to localhost from emacs
run lein upgrade
upgrade to the latest version of the cider emacs package
ask in the cider channel on clojure slack before submitting bug reports.
It used to be required to add cider's nrepl middleware to your lein profile to get it included on the classpath when lein start up. Now cider does this automatically and chooses the matching version on it's own. Many people are following instructions from when this was a manual process and run into problems like this, so check that first.
Remove your ~/.emacs.d directory and install spacemacs instead
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
Once you run Emacs with the new spacemacs ~/.emacs.d directory, you can simply open up a Clojure file and spacemacs will load in the Clojure layer for you.
More details can be found at spacemacs.org and in this tutorial on clojure development with spacemacs https://practicalli.github.io/spacemacs/
So the error appears to be in cider-client.el at line 102 https://github.com/clojure-emacs/cider/blob/master/cider-client.el#L99. I've got the whole defun posted below:
(defun cider-repl-buffers ()
"Return the list of REPL buffers."
(seq-filter
(lambda (buffer)
(with-current-buffer buffer (derived-mode-p 'cider-repl-mode)))
(buffer-list)))
Can you visit this file in your CIDER copy and ensure that this definition looks like this. This code is just looking for repl buffers and is filtering the buffers that emacs knows about.
Related
I've got this in my init.el:
(require 'package)
(package-initialize)
(setq package-enable-at-startup nil)
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Bootstrapping use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile (require 'use-package))
(use-package use-package
:config
(setq use-package-always-ensure t))
As far as I understand, this should be good to install all the packaged listed in
'(package-selected-packages
(quote
(org org-plus-contrib org-ref techela tuareg haskell-mode gnuplot gnuplot-mode helm-ispell ac-ispell paredit ox-tufte auctex json org-grep iedit wgrep helm geiser slime-company company-jedi zzz-to-char rainbow-delimiters avy ivy projectile twittering-mode zerodark-theme pretty-mode flycheck-clang-analyzer flycheck-irony flycheck yasnippet company-c-headers company-shell company-irony irony irony-mode company-lua mark-multiple expand-region popup-kill-ring dmenu ido-vertical-mode ido-vertical ox-html5slide centered-window-mode htmlize ox-twbs diminish erc-hl-nicks symon rainbow-mode switch-window dashboard smex company sudo-edit emms magit org-bullets hungry-delete beacon linum-relative spaceline fancy-battery exwm use-package)))
which is inside my custom-set-variables. However, when I do a first-time, clean (no existing elpa/ directory) startup of Emacs reading this init.el, not all of the packages are gotten and installed. But then I can do a package-install-selected-packages and, Emacs reports that it doesn't have anything in package-selected-packages. Looking at the variable confirms this. What could be going wrong? An older "working" version of this (with existing elpa/ directory) responds oddly to package-install-selected-packages, wanting to install e.g., auctex and some nine other packages that the package code above apparently isn't seeing or dealing with. I'm baffled as to why package-selected-packages seems to be so flaky for me. I'm assuming my older .emacs.d with the existing elpa/ has install info that is "working around" this failing package-selected-packages situation.
I am new to Emacs and perhaps that is the problem but I was following the instructions here:
https://github.com/ProofGeneral/PG
in particular after I added the given lines to my .emacs file, I did (M is the alt/option key):
M-x package-refresh-contents RET
but I got the error message:
[no match]
what is going wrong?
maybe this what I am doing wrong, what does:
M-x package-refresh-contents RET followed by M-x package-install RET proof-general RET
mean?
This is what works for me (TM):
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
;; Bootstrap use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(use-package proof-general
:no-require t
:ensure t)
The line will work if you have melpa as your package source. See the answer of ejgallego:
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
If you add these lines to your .emacs - file and then
M-x package-refresh-contents (followed by return)
M-x package-install (followed by return and then `proof-general`)
then it will work without explicitly adding the package in your .emacs-file.
Brand-new Emacs 24.5 64-bit install on Win7 did not seem to include an init.el file and I needed one for settings for a plug-in I want to use, so I created one in Emacs at C:\Users\brinklec\AppData\Roaming.emacs.d. Restarting Emacs, got the apparently famous
Warning (initialization): An error occurred while loading `c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el':
File error: Cannot open load file, no such file or directory, use-package
I did not initially understand the reference to "use-package" at the end of the error, and the preceding wording apparently misled me to think it was init.el that Emacs was saying it c ould not load.
Manual load gives the same error. However, Emacs can open and successfully resave the file.
I saw a bunch of similar issues, but all seemed to involve other files referenced in an already existing and successfully loaded init.el. I thought my issue was different, but now maybe not?
Contents of my init.el come from recommended config for ENSIME plug-in (verbatim except for first comment line below):
;;; ~/.emacs.d/init.el
;; global variables
(setq
inhibit-startup-screen t
create-lockfiles nil
make-backup-files nil
column-number-mode t
scroll-error-top-bottom t
show-paren-delay 0.5
use-package-always-ensure t
sentence-end-double-space nil)
;; buffer local variables
(setq-default
indent-tabs-mode nil
tab-width 4
c-basic-offset 4)
;; modes
(electric-indent-mode 0)
;; global keybindings
(global-unset-key (kbd "C-z"))
;; the package manager
(require 'package)
(setq
use-package-always-ensure t
package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
Debug output from --debug-init:
Debugger entered--Lisp error: (file-error "Cannot open load file" "no such file or directory" "use-package")
require(use-package)
eval-buffer(#<buffer *load*> nil "c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el" nil t) ; Reading at buffer position 841
load-with-code-conversion("c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el" "c:/Users/brinklec/AppData/Roaming/.emacs.d/init.el" t t)
load("c:/Users/brinklec/AppData/Roaming/.emacs.d/init" t t)
#[0 "\205\262
Adding the following expression right before the final (require 'use-package) seems to have resolved the error (though I'm also no longer getting the helpful greeting screen on startup):
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
I have Emacs24, i want to use some modes like auto-complete.
Here is the thing, I installed 'linum' before and it's just working very well but others not working.
My .emacs file
(add-to-list 'load-path "/root/.scripts")
(require 'linum)
(global-linum-mode 1)
(require 'package)
(add-to-list 'package-archives '("melppa" . "http://melpa.milkbox.net/packages/"))
(package-initalize)
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
(require 'yasnippet)
auto-complete and yasnippet just doesn't working , i tried command 'auto-complete-mode' but its still same.
Any ideas ?
EDIT : I installed it from source not from ELPA and it worked.
I had a similar issue when I upgraded to Emacs 24. Have you tried running M-x auto-complete? When I did, I got an error message like the following:
gv-get: (popup-cursor ac-menu) is not a valid place expression
It turned out this was an already reported bug that can be fixed by recompiling your byte-code:
https://github.com/auto-complete/auto-complete/issues/222
https://github.com/auto-complete/auto-complete/issues/118
This solution worked for me:
$ find ~/.emacs.d/elpa -name '*.elc' | xargs rm
(to remove all compiled elisp in your elpa subdirectories)
... then, in an elisp interaction buffer, like scratch eval:
(byte-recompile-directory (expand-file-name "~/.emacs.d/elpa") 0)
... then re-start emacs.
I made the mistake of updating my existing ports with MacPorts -- now slime and swank-clojure no longer work. I get the following message when I invoke clojure-jack-in within emacs:
Versions differ: 2011-04-16 (slime) vs. 20100404 (swank). Continue? (y or n)
Entering y will bring up the slime REPL, but then when I try to evaluate an expression in the REPL, I get another message:
Not connected. Use `M-x slime' to start a Lisp.
What is going on here?
Here are the relevant portions of my init.el file:
;; slime
(setq inferior-lisp-program "/opt/local/bin/sbcl")
(add-to-list 'load-path
"/opt/local/share/emacs/site-lisp/slime"
"/opt/local/share/emacs/site-lisp/slime/contrib")
(add-hook 'slime-repl-mode-hook
(defun clojure-mode-slime-font-lock()
(require 'clojure-mode)
(let (font-lock-mode)
(clojure-mode-font-lock-setup))))
(require 'slime)
(slime-setup '(slime-repl))
(eval-after-load "slime" '(slime-setup '(slime-fancy slime-banner)))
;; clojure
(add-to-list 'load-path
"~/.emacs.d/elpa/clojure-mode-el"
"~/.emacs.d/elpa/paredit-22")
(require 'clojure-mode)
(defun turn-on-paredit () (paredit-mode 1))
(add-hook 'clojure-mode-hook 'turn-on-paredit)
swank-clojure only works with slime version 20100404:
https://github.com/technomancy/swank-clojure/issues/120#issuecomment-4862556
only option at this point is to downgrade version of slime.