File mode specification error: (file-error "Cannot open load file" "~/.emacs.d/abbrev_defs") [2 times]

Bug #1015713 reported by Barry Warsaw on 2012-06-20
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
High
Andreas Roehler

Bug Description

Latest bzr trunk gives me lots of these errors in *Messages*

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
importance: Undecided → High
Andreas Roehler (a-roehler) wrote :

hmm, maybe var abbrev-file-name is set to this, but the file doesn't exist, resp. is not readable?

On Jun 20, 2012, at 06:25 PM, Andreas Roehler wrote:

>hmm, maybe var abbrev-file-name is set to this, but the file doesn't
>exist, resp. is not readable?

This is true, but this seems like a new requirement for python-mode, so at the
very least it needs to be documented in the release notes.

Andreas Roehler (a-roehler) wrote :

Am 20.06.2012 20:38, schrieb Barry Warsaw:
> On Jun 20, 2012, at 06:25 PM, Andreas Roehler wrote:
>
>> hmm, maybe var abbrev-file-name is set to this, but the file doesn't
>> exist, resp. is not readable?
>
> This is true, but this seems like a new requirement for python-mode, so at the
> very least it needs to be documented in the release notes.
>

it is.

BTW you should not see this error when simply loading python-mode.el, even if the abbrev-file doesn't exist.
If you try to use the abbrev commands without, well, that's a broken install than :)

Cheers,

Andreas

Andreas Roehler (a-roehler) wrote :

Am 20.06.2012 20:38, schrieb Barry Warsaw:
> On Jun 20, 2012, at 06:25 PM, Andreas Roehler wrote:
>
>> hmm, maybe var abbrev-file-name is set to this, but the file doesn't
>> exist, resp. is not readable?
>
> This is true, but this seems like a new requirement

Hi Barry,

to be more precise in this point: no, there is no new requirement.

Only if the abbrev commands are used, a possibly broken abbrevs handling will display its errors.

Cheers,

Andreas

Barry Warsaw (barry) wrote :

On Jun 20, 2012, at 07:12 PM, Andreas Roehler wrote:

>BTW you should not see this error when simply loading python-mode.el, even if
>the abbrev-file doesn't exist. If you try to use the abbrev commands
>without, well, that's a broken install than :)

The problem is that you see this error when you load a .py file, even if you
don't explicitly use any abbrev commands. Maybe some abbrev commands are
being used implicitly?

Andreas Roehler (a-roehler) wrote :

Am 20.06.2012 21:40, schrieb Barry Warsaw:
> On Jun 20, 2012, at 07:12 PM, Andreas Roehler wrote:
>
>> BTW you should not see this error when simply loading python-mode.el, even if
>> the abbrev-file doesn't exist. If you try to use the abbrev commands
>> without, well, that's a broken install than :)
>
> The problem is that you see this error when you load a .py file, even if you
> don't explicitly use any abbrev commands. Maybe some abbrev commands are
> being used implicitly?
>

there is an

(custom-add-option 'python-mode-hook 'abbrev-mode)

this option is nil with emacs -Q however, so it should not interfere.

Beside this only commands are delivered, don't see any auto-call to them

Maybe start from emacs -Q end send a complete output?

Andreas

Titus Barik (7-titus) wrote :

Using an init.el containing only the following:

(add-to-list 'load-path "~/.emacs.d/python-mode/")
(setq py-install-directory "~/.emacs.d/python-mode/")
(require 'python-mode)

I also receive this error upon opening a .py file:

File mode specification error: (file-error "Cannot open load file" "~/.emacs.d/abbrev_defs")
Wrote c:/Users/tbarik/Documents/tmp/hello.py

This is under Windows 7 x64 using Emacs 24.1.1 (i386-mingw-nt6.1.7601). I am not skilled enough with EmacsLisp to even begin to diagnose this issue, unfortunately.

Andreas Roehler (a-roehler) wrote :

Am 21.06.2012 16:35, schrieb Titus Barik:
> Using an init.el containing only the following:
>
> (add-to-list 'load-path "~/.emacs.d/python-mode/")
> (setq py-install-directory "~/.emacs.d/python-mode/")
> (require 'python-mode)
>
> I also receive this error upon opening a .py file:
>
> File mode specification error: (file-error "Cannot open load file" "~/.emacs.d/abbrev_defs")
> Wrote c:/Users/tbarik/Documents/tmp/hello.py
>
> This is under Windows 7 x64 using Emacs 24.1.1 (i386-mingw-nt6.1.7601).
> I am not skilled enough with EmacsLisp to even begin to diagnose this
> issue, unfortunately.
>

Hi Barry and Titus,

think got the reasons so far: in line 13026 python-mode.el

;;;;;;;;;
;; FixMe: for unknown reasons this is not done by mode
(add-hook 'python-mode-hook '(lambda () (load abbrev-file-name nil t)))
;;;;;;;;;

remains the question: bug or not?

IMO value of abbrev-file-name is a system-file for Emacs. It always exists, unless killed deliberately.

Any reasons to delete that file?
If not, just specifying should solve the issue.

Cheers,

Andreas

Titus Barik (7-titus) wrote :

Here's what I have (from C-h v abbrev-file-name RET):

abbrev-file-name is a variable defined in `abbrev.el'.
Its value is "~\\.emacs.d\\abbrev_defs"

I don't have the file abbrev_defs, though I'm curious how that gets created in the first place. It doesn't seem to appear even if I delete my .emacs.d folder. I suppose I could create the file myself.

Titus Barik (7-titus) wrote :

Yup, doing an M-x edit-abbrevs created the file and removed the error. So I'm not sure if it's a bug or not, except to say that it doesn't seem like it can be assumed that the actual abbrev_defs necessarily exists.

Andreas Roehler (a-roehler) wrote :

Am 21.06.2012 18:23, schrieb Titus Barik:
> Here's what I have (from C-h v abbrev-file-name RET):
>
> abbrev-file-name is a variable defined in `abbrev.el'.
> Its value is "~\\.emacs.d\\abbrev_defs"
>
> I don't have the file abbrev_defs, though I'm curious how that gets
> created in the first place. It doesn't seem to appear even if I delete
> my .emacs.d folder. I suppose I could create the file myself.
>

Creating an empty file should do it.
BTW will check in a fix, will will issue a warning in this case, but avoid the error.

An alternative would be to create that file silently.

Barry, WDYT?

Barry Warsaw (barry) wrote :

On Jun 21, 2012, at 05:04 PM, Titus Barik wrote:

>Yup, doing an M-x edit-abbrevs created the file and removed the error.
>So I'm not sure if it's a bug or not, except to say that it doesn't seem
>like it can be assumed that the actual abbrev_defs necessarily exists.

I think it's a bug. The error shouldn't occur just on visiting a .py file.

Barry Warsaw (barry) wrote :

On Jun 21, 2012, at 05:05 PM, Andreas Roehler wrote:

>Am 21.06.2012 18:23, schrieb Titus Barik:
>> Here's what I have (from C-h v abbrev-file-name RET):
>>
>> abbrev-file-name is a variable defined in `abbrev.el'.
>> Its value is "~\\.emacs.d\\abbrev_defs"
>>
>> I don't have the file abbrev_defs, though I'm curious how that gets
>> created in the first place. It doesn't seem to appear even if I delete
>> my .emacs.d folder. I suppose I could create the file myself.
>>
>
>Creating an empty file should do it.
>BTW will check in a fix, will will issue a warning in this case, but avoid the error.
>
>An alternative would be to create that file silently.
>
>Barry, WDYT?

I don't think we should create the file silently. It seems like python-mode
should be a client of abbrev and not try to initialize things for it. A
warning is I suppose better than an error, but even better still would be to
just conditionalize it on whether abbrev is already set up and initialized.

(Or I guess we should ask whether python-mode has any business setting up
abbrev anyway? Why wouldn't that just be left up to the end user?)

Andreas Roehler (a-roehler) wrote :

Am 21.06.2012 19:42, schrieb Barry Warsaw:
> On Jun 21, 2012, at 05:05 PM, Andreas Roehler wrote:
>
>> Am 21.06.2012 18:23, schrieb Titus Barik:
>>> Here's what I have (from C-h v abbrev-file-name RET):
>>>
>>> abbrev-file-name is a variable defined in `abbrev.el'.
>>> Its value is "~\\.emacs.d\\abbrev_defs"
>>>
>>> I don't have the file abbrev_defs, though I'm curious how that gets
>>> created in the first place. It doesn't seem to appear even if I delete
>>> my .emacs.d folder. I suppose I could create the file myself.
>>>
>>
>> Creating an empty file should do it.
>> BTW will check in a fix, will will issue a warning in this case, but avoid the error.
>>
>> An alternative would be to create that file silently.
>>
>> Barry, WDYT?
>
> I don't think we should create the file silently. It seems like python-mode
> should be a client of abbrev and not try to initialize things for it. A
> warning is I suppose better than an error, but even better still would be to
> just conditionalize it on whether abbrev is already set up and initialized.

okay, think I have the resp. solution. An abbrev-file will be read only after check if it exists.
As Titus remarked, editing abbrevs will create the file.

>
> (Or I guess we should ask whether python-mode has any business setting up
> abbrev anyway? Why wouldn't that just be left up to the end user?)
>

the only diff to common proceeding is that explicit reading of the abbrevs by that hook.
Commonly abbrevs are read by the mode without any hook needed. Dunno why it doesn't work.
Without that hook, the mode-abbrevs table remains empty after restart.

Changed in python-mode:
status: New → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers