简体   繁体   中英

Emacs: Cannot open load file, go-autocomplete

I'm trying to install [gocode][1] on Emacs currently and am receiving the current error message:

Warning (initialization): An error occurred while loading `/home/darwin/.emacs':

File error: Cannot open load file, no such file or directory, go-autocomplete

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.

And when I run Emacs with --debug-init, I receive this (it's not too pretty):

Debugger entered--Lisp error: (file-error "Cannot open load file" "no such file or directory" "go-autocomplete")
  require(go-autocomplete)
  eval-buffer(#<buffer  *load*> nil "/home/darwin/.emacs" nil t)  ; Reading at buffer position 1831
  load-with-code-conversion("/home/darwin/.emacs" "/home/darwin/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\262�    \306=\203�\307\310Q\202;�   \311=\204�\307\312Q\202;�\313\307\314\315#\203*�\316\202;�\313\307\314\317#\203:�\320\nB\321\202;�\316\322\323\322\211#\210\322=\203a�\324\325\326\307\327Q!\"\323\322\211#\210\322=\203`�\210\203\243�\330!\331\232\203\243�\332!\211\333P\334!\203}�\211\202\210�\334!\203\207�\202\210�\314\262\203\241�\335\"\203\237�\336\337#\210\340\341!\210\266\f?\205\260�\314\323\342\322\211#)\262\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" (initialization "`_emacs' init file is deprecated, please use `.emacs'") "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7 "\n\n(fn)"]()
  command-line()
  normal-top-level()

I've installed the Emacs (regular) autocomplete version required for gocode using the package manager (gocode isn't available on this manager by the way).

My directories if they help: Emacs folder is called: .emacs.d :

/.emacs.d
  /auto-save-list
  /elpa
  go-autocomplete.el

Emacs init folder:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-enabled-themes (quote (misterioso)))
 '(inhibit-startup-screen t))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(when (>= emacs-major-version 24)
  (require 'package)
  (package-initialize)
 ; (add-to-list 'package-archives
                    ;          '("melpa-stable" . "http://stable.melpa.org/packages/") t)
  (add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
  (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t)
  (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
  )


;; Update Emacs config for godoc
(setenv "PATH" "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin")
(setenv "GOPATH" "~/go")

;; calls gofmt before save
(setq exec-path (cons "/usr/local/go/bin" exec-path))
(add-to-list 'exec-path "/go/bin")
;(add-hook 'before-save-hook 'gofmt-before-save)
(defun my-go-mode-hook ()
  ; Call Gofmt before saving
  (add-hook 'before-save-hook 'gofmt-before-save)
  ; Customize compile command to run go build
  (if (not (string-match "go" compile-command))
      (set (make-local-variable 'compile-command)
           "go build -v && go test -v && go vet"))
  ; Godef jump key binding
  (local-set-key (kbd "M-.") 'godef-jump))
(add-hook 'go-mode-hook 'my-go-mode-hook)

;; Gocode: Go aware Autocomplete
(require 'go-autocomplete)
(require 'auto-complete-config)
;; Go eldoc (via package control) REQUIRES GOCODE
(require 'go-eldoc)
(add-hook 'go-mode-hook 'go-eldoc-setup)

If anyone could help me figure out how I can get gocode to work that would be fantastic. Thank you in advance.

PS I can add other directories if needed. [1]: https://github.com/nsf/gocode

The root directory of .emacs.d is not generally a part of the load-path , and recent versions of Emacs will even give the user a warning message discouraging against doing it if in fact a user did it. Create a sub-folder called lisp or hello-world and put your library inside it and then add the lisp or hello-world directory to your load-path and restart Emacs. Here is a link to the related documentation for load-path : https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html

Example (place inside .emacs file):

(add-to-list 'load-path "/path/to/my/lisp/library")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM