Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snippets/go-mode/default: Invalid Read Syntax: "#" on Emacs development #521

Closed
rye opened this issue Oct 2, 2014 · 13 comments
Closed

snippets/go-mode/default: Invalid Read Syntax: "#" on Emacs development #521

rye opened this issue Oct 2, 2014 · 13 comments

Comments

@rye
Copy link

rye commented Oct 2, 2014

I'm currently running a version of Emacs that updates nightly to the latest Emacs version of the Git clone of the BZR repo. Today, I noticed a problem with loading, which prevents yasnippet from loading entirely:

Debugger entered--Lisp error: (invalid-read-syntax "#")
  eval-buffer(#<buffer  *load*> nil "/home/krye/.emacs.d/elpa/yasnippet-20140929.240/snippets/go-mode/default" nil t)  ; Reading at buffer position 2
  load-with-code-conversion("/home/krye/.emacs.d/elpa/yasnippet-20140929.240/snippets/go-mode/default" "/home/krye/.emacs.d/elpa/yasnippet-20140929.240/snippets/go-mode/default" t t)
  load("default" 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]()
  command-line()
  normal-top-level()

Any ideas? I'll be glad to test any patches or pull requests.

@joaotavora
Copy link
Owner

Any ideas?

No. Sorry, but I need a way to reliably reproduce the error. Read https://github.com/capitaomorte/yasnippet#important-note-regarding-bug-reporting

FWIW I'm also running fairly recent emacsen.

I will reopen this issue once you provide this information.

@rye
Copy link
Author

rye commented Oct 2, 2014

I just updated Emacs to no avail—still the same problem.

Currently running off of the following commit (obtained using git log -1):

commit 9722cc67f2c4e13d5758b9bc73c0e1b6acbabe8e
Author: Dmitry Antipov <dmantipov@yandex.ru>
Date:   Thu Oct 2 18:01:27 2014 +0400

    * alloc.c (mark_overlay): Assume that overlay boundaries are
    always markers.  Add comment.
    * lread.c (read_internal_start): Use convenient validate_subarray.
    Adjust docstring.
    (Fread_from_string): Adjust docstring.

I suppose it may be a problem with my configuration, seeing as when I run the following code in a emacs -Q instance, I can run (require 'yasnippet) just fine:

(setq load-path (cons (expand-file-name "~/.emacs.d/elpa/yasnippet-20140929.240/") load-path)))

I'll investigate further.

@npostavs
Copy link
Collaborator

npostavs commented Oct 2, 2014

This is the same as AndreaCrotti/yasnippet-snippets#55. I think the problem is that package.el adds the snippet directories to the load-path so a snippet called "default" overrides the elisp "default" library.

startup.el:

(defun command-line ()
  "A subroutine of `normal-top-level'.
Amongst another things, it parses the command-line arguments."
...
                      (unless inhibit-default-init
                        (let ((inhibit-startup-screen nil))
                          ;; Users are supposed to be told their rights.
                          ;; (Plus how to get help and how to undo.)
                          ;; Don't you dare turn this off for anyone
                          ;; except yourself.
                          (load "default" t t)))

@joaotavora
Copy link
Owner

@npostavs well spotted, is there a way to prevent snippet directories from being added to the load-path? According to the doc of normal-top-level-add-subdirs-to-load-path, placing a .nosearch file in a directory prevents it from adding the file to the laod path so if package.el uses that, this would be an easy fix, no?

@treese
Copy link
Contributor

treese commented Oct 4, 2014

As a workaround for this problem until a complete fix is sorted out, it usually suffices to put (setq inhibit-default-init t) in .emacs. This keeps Emacs from looking for "default", and most installations don't have a default file that matters.

@joaotavora
Copy link
Owner

@treese and @rye I still haven't understood very well from this thread what is a reproducible way to see the error happening. I'm guessing it happens only with very recent emacsen, and when yasnippet is required from the user's init file.

I would try to add an empty .nosearch to the snippets/ subdir then. And if it works I would submit that change to yasnippet-snippets.

@treese
Copy link
Contributor

treese commented Oct 4, 2014

I ran into it by installing the yasnippets package using the package system, which then seems to automatically add a huge number of directories to the load-path. I am using Aquamacs 3.0 on a Mac, which is based on Emacs version 24.3.50.2. I will try the .nosearch file.

@npostavs
Copy link
Collaborator

npostavs commented Oct 4, 2014

I ran into it by installing the yasnippets package using the package system, which then seems to automatically add a huge number of directories to the load-path.

Hmm, I just tried that with emacs 24.3.3 and 24.3.94.1 and it didn't happen to me.

@npostavs
Copy link
Collaborator

npostavs commented Oct 4, 2014

Maybe it's not from package.el. @rye, @treese: do you possibly have something like

(normal-top-level-add-to-load-path "~/.emacs.d")

in your init.el?

@rye
Copy link
Author

rye commented Oct 4, 2014

In my former Emacs configuration (since opening this issue, I've started work on a new one—it was time for one anyways), I did have something like that. It appears that Emacs was trying to load the snippets as LISP code (?).

From my original configuration, I had the following code getting called on startup:

;; file: init-lib.el
(defun init--add-directory-to-load-path (path)
  "Adds a directory to the load-path"

  (let ((default-directory path))
    (setq load-path
          (append
           (let ((load-path (copy-sequence load-path)))
             (normal-top-level-add-subdirs-to-load-path))
           load-path)))
  (message "Added %s to the load-path" path))

(provide 'init-lib)

and it was getting called like so:

;; file: init.el

(load-file "~/.emacs.d/init-lib.el")
(require 'init-lib)

(init--add-directory-to-load-path "~/.emacs.d/elpa/")
(init--add-directory-to-load-path "~/.emacs.d/lisp/")

So it is very possible that code that was called after that was trying to load the snippets as Emacs-Lisp code. I'm not sure, though. One of the reasons I started rewriting my config was that it was just a jumbled mess that was pretty hard to understand, and was very inconsistent.

So far, I haven't run into this problem on my fresh config. I think that it might have been a code completion package that was causing these problems in my former config—I seem to remember some -eldoc package in the backtrace when I was debugging this at first. I'll report if any specific package causes this breakage again, and I'll open an issue with that package's developers also. I think that having a .nosearch file, if it works properly, would be a good safeguard for yasnippet-snippets to have employed.

@joaotavora
Copy link
Owner

think that having a .nosearch file, if it works properly, would be a good safeguard for yasnippet-snippets to have employed.

Can you try it and report back here, please?

@treese
Copy link
Contributor

treese commented Oct 4, 2014

I tried .nosearch and it seems to solve the problem. I submitted it as a pull request on yasnippet-snippets.

@joaotavora
Copy link
Owner

Nice one @treese

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants