byte-compile errors - emacs

I want to byte-compile some el files in my .emacs.d directory.I wrote a file like this:
cl.el:
(add-to-list 'load-path "~/.emacs.d/slime/")
(require 'slime)
and someother code.when i byte-compile it,the error is:
Error: Cannot open load file: slime
however,i really put the slime package in the directory.
and i use the batch-byte-compile also find that all el files contain
(require '***)
will result out the similar error

~ does not get expanded; use an absolute path, or (add-to-list 'load-path (expand-file-name "~/.emacs.d/slime/")).
This is unrelated to byte compilation, per se.

Related

Calling (require ...) on a MELPA installed package gives FlyCheck error "Cannot open load file"

I want to require some packages installed through MELPA so that i can access their variables and functions without getting "free variable" or "undefined function" warnings.
However, when I try to load a package it isn't found by Flycheck and i get a "Cannot open load file" error. It seems that the bytecode compiler doesn't read into the directory with the files installed by MELPA, but I don't know how to solve this.
I'm using Emacs 26.3 with Purcell's config that includes Flymake-Flycheck. This snippet covers the relevant parts of the init-elpa.el custom files where you can see the at the end that even if I install and then (require ...) a package it still is marked with an error by Flycheck.
;;; init-elpa.el --- Settings and helpers for package.el -*- lexical-binding: t -*-
(require 'package)
(require 'cl-lib)
;;; Install into separate package dirs for each Emacs version, to prevent bytecode incompatibility
(setq package-user-dir
(expand-file-name (format "elpa-%s.%s" emacs-major-version emacs-minor-version)
user-emacs-directory))
;;; Standard package repositories
(add-to-list 'package-archives '( "melpa" . "https://melpa.org/packages/") t)
(defun require-package (package &optional min-version no-refresh)
"Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
...)
(defun maybe-require-package (package &optional min-version no-refresh)
"Try to install PACKAGE, and return non-nil if successful.
In the event of failure, return nil and print a warning message.
Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the
available package lists will not be re-downloaded in order to
locate PACKAGE."
...)
;;; Fire up package.el
(setq package-enable-at-startup nil)
(package-initialize)
(defvar sanityinc/required-packages nil)
(defun sanityinc/note-selected-package (oldfun package &rest args)
"If OLDFUN reports PACKAGE was successfully installed, note that fact.
The package name is noted by adding it to
`sanityinc/required-packages'. This function is used as an
advice for `require-package', to which ARGS are passed."
...)
(advice-add 'require-package :around 'sanityinc/note-selected-package)
(when (fboundp 'package--save-selected-packages)
(require-package 'seq)
(add-hook 'after-init-hook
(lambda ()
(package--save-selected-packages
(seq-uniq (append sanityinc/required-packages package-selected-packages))))))
;; READ HERE: now i try to install and require some packages.
(require-package 'fullframe)
(require-package 'evil)
(require 'fullframe) ;; Flycheck gives an ERROR: cannot open load file, files or directory does not exist
(require 'evil) ;; same as above
(require 'python) ;;this gives no error, since it's built-in i guess.
(provide 'init-elpa)
;;; init-elpa.el ends here
You can see that (package-initialize) is called so the load-path should be set. Also, I have flycheck-emacs-lisp-load-path set to 'inherit, which should mean that the bytecode compiler reads the same dirs as a normal emacs instance.
What should I do in order to make the bytecode compiler recognize my ELPA directory?
Check out flycheck-emacs-lisp-load-path variable
flycheck-emacs-lisp-load-path is a variable defined in ‘flycheck.el’.
... When set to ‘inherit’, use the ‘load-path’ of the current Emacs
session during syntax checking.
E.g you could do:
(use-package flycheck
:diminish ""
:custom
(flycheck-emacs-lisp-load-path 'inherit)
...

Running racket with emacs?

I installed Geiser from source and following this SO answer set the path to drracket.
Here is my part of my .emacs file. I'm on a GNU/linux distribution.
;;;;;;;;;;;;;;;;
;Geiser
;downloaded geiser from git rep and make install
;;;;;;;;;;;;;;
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/")
(require 'geiser-install)
(setq geiser-racket-binary "/usr/racket/bin/drracket")
In emacs when I M-x run-racket on emacs I get the following error:
drracket: unknown switch: -i
Do you have any solution?
Of course the solution was to use
(setq geiser-racket-binary "/usr/racket/bin/racket")
instead of :
(setq geiser-racket-binary "/usr/racket/bin/drracket")

Emacs24 auto-complete mode does not work

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.

Emacs sr-speedbar cannot open loadfile, sr-speedbar

I'm having difficulty following the instructions for installing speedbar on Emacs.
step 1. Put Lisp:sr-speedbar.el in your load-path, add
(require 'sr-speedbar)
ok put "sr-speedbar.el" in my load-path. (first of all I am making the assumption my load-path is my .emacs.d directory in my root directory.
I go to this link: http://www.emacswiki.org/emacs/sr-speedbar.el
hit the download button, which I end up having to copy/paste the entire file, save it as sr-speedbar.el inside my .emacs.d directory.
~/.emacs.d now has sr-speedbar.el and my .emacs file has the below code:
1 (add-to-list 'load-path "~/.emacs.d/evil")..
2 (require 'evil)..
3 (evil-mode 1)
4 (require 'sr-speedbar)
~
~
so i close out emacs, open it back up and get this error:
Warning (initialization): An error occurred while loading `/Users/johncurry/.emacs':
File error: Cannot open load file, sr-speedbar
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
so I $ emacs --debug-init
Debugger entered--Lisp error: (file-error "Cannot open load file" "sr-speedbar"$
require(sr-speedbar)
eval-buffer(#<buffer *load*> nil "/Users/johncurry/.emacs" nil t) ; Reading$
load-with-code-conversion("/Users/johncurry/.emacs" "/Users/johncurry/.emacs"$
load("~/.emacs" t t)
#[0 "^H\205\262^# \306=\203^Q^#\307^H\310Q\202;^# \311=\204^^^#\307^H\312$
command-line()
normal-top-level()
sr-speedbar-open returns no match inside emacs. Any idea how to get this wrong? I'm sure it's just me not understanding the instructions, but I need help with this.
I had the same problem. When I checked the load path of emacs I found that the ~/.emacs.d directory wasn't part of the path.
You can check you load-path use the following command
C-h v load-path RET
To add the path I added the following to my .emacs file.
;; Add the ~/.emacs.d/lisp directory and all subdirectories to the load path of emacs
(let ((default-directory "~/.emacs.d/lisp/"))
(normal-top-level-add-subdirs-to-load-path))
I already had some files in the .emacs.d directory so I add a lisp directory so I wouldn't break anything.
I then reloaded my .emacs file and everything worked.
To reload your .emacs file use the following command
M-x load-file RET .emacs RET
source: https://www.emacswiki.org/emacs/LoadPath

Installing YASnippet

I have installed YASnippet and configured it with this:
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle
(yas--initialize)
(yas/load-directory "~/.emacs.d/packages/yasnippet-0.6.1c/snippets")
However, when I launch Emacs it gives me an error:
Warning (initialization): An error occurred while loading `/home/alexander/.emacs':
Symbol's function definition is void: yas--initialize
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle
(yas--initialize)
(yas/load-directory "~/.emacs.d/packages/yasnippet-0.6.1c/snippets")
What am I doing wrong? I have tried to find the answer but with no success. (I have also tried with another version of yasnippet yasnippet-0.6.1b but it was the same.)
Just at a glance, that
(yas--initialise)
should be
(yas/initialize)
I'm running 0.6.1 and there's no such function as yas--initialize in the package.
My init code looks like
(require 'yasnippet)
(yas/initialize)
(yas/load-directory
(dot-emacs "elpa/yasnippet-0.6.1/snippets"))
I think you just got some garbled init code somewhere.
EDIT
I should have omitted the load-directory call in my sample since it's beside the point. But for what it's worth, dot-emacs is just a config-agnostic function I use to reference files relative to my init:
(defun dot-emacs (relative-path)
"Return the full path of a file in the user's emacs directory."
(expand-file-name (concat user-emacs-directory relative-path)))
FYI in case you ever upgrade: the information you got is correct for version 0.8, but for 0.7 and below yas/initialize is correct.
See this commit