[vim/vim] Error detected while processing BufRead Autocommands for "*.inp"..function (Issue #10391)

572 views
Skip to first unread message

Vasu Kolli

unread,
May 9, 2022, 10:09:16 AM5/9/22
to vim/vim, Subscribed

Steps to reproduce

  1. Extract the zip folder test.zip. It contains only one file test.inp
  2. Open the test.inp file with gvim.
  3. Press :e and then ENTER. Then you get the following error.
Error detected while processing BufRead Autocommands for "*.inp"..function dist#ft#Check_inp[2]..FileType Autocommands for "*"..function <SNR>17_LoadFTPlugin:
line    3:
E1269: Cannot create a Vim9 script variable in a function: s:cpo_save

Expected behaviour

It should not have this warning or error.

I have no plugins. The output can also be replicated running gvim -u DEFAULTS. I do not have .vim folder.

My ~/.vimrc looks as follows:

colorscheme evening
set guifont=Monospace\ 11
" visualizes line number
set number
set nocompatible
syntax enable
syntax on
" autoupdates file
set autoread
filetype plugin indent on
" sets the window to maximized when opened
set lines=999 columns=999
" updates file after buffer change
au FocusGained,BufEnter *.* :checktime
" keymap for :e = reloading the current buffer
nnoremap <F5> :edit<CR>
" list the contents of the current folder
nnoremap <F6> :!ls<CR>
" source ~/.vimrc
nnoremap <F7> :so $MYVIMRC<CR>

Version of Vim

VIM - Vi IMproved 8.2

Environment

OS: Manjaro - Arch Linux
output of $TERM: xterm-256color
shell: bash (but the problem at hand pertains to GVim not vi)
Terminal: konsole (but the problem at hand pertains to GVim not vi)

Logs and stack traces

I do not know what these mean.  Please write to me how I can get them, if you need them


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10391@github.com>

lacygoill

unread,
May 9, 2022, 10:22:10 AM5/9/22
to vim/vim, Subscribed

I think that's because the abaqus filetype plugin tries to save a script-local variable from b:undo_ftplugin which is wrong, because the latter is run in the global context, where any item in the script-local namespace is not available.

Patch fixing the issue:

diff --git a/runtime/ftplugin/abaqus.vim b/runtime/ftplugin/abaqus.vim
index b263d0c31..42e58c2da 100644
--- a/runtime/ftplugin/abaqus.vim
+++ b/runtime/ftplugin/abaqus.vim
@@ -86,11 +86,11 @@ let b:undo_ftplugin .= "|unmap <buffer> [[|unmap <buffer> ]]"
     \ . "|unmap <buffer> <LocalLeader><LocalLeader>"
 
 " Undo must be done in nocompatible mode for <LocalLeader>.
-let b:undo_ftplugin = "let s:cpo_save = &cpoptions|"
+let b:undo_ftplugin = "let b:cpo_save = &cpoptions|"
     \ . "set cpoptions&vim|"
     \ . b:undo_ftplugin
-    \ . "|let &cpoptions = s:cpo_save"
-    \ . "|unlet s:cpo_save"
+    \ . "|let &cpoptions = b:cpo_save"
+    \ . "|unlet b:cpo_save"
 
 " Restore saved compatibility options
 let &cpoptions = s:cpo_save


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10391/1121168652@github.com>

Bram Moolenaar

unread,
May 9, 2022, 11:11:34 AM5/9/22
to vim/vim, Subscribed

Closed #10391.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/10391/issue_event/6574055498@github.com>

Bram Moolenaar

unread,
May 9, 2022, 11:11:58 AM5/9/22
to vim/vim, Subscribed

Looks like this plugin hasn't changed in ten years. Let me just include that fix now.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10391/1121229781@github.com>

Vasu Kolli

unread,
May 9, 2022, 11:58:35 AM5/9/22
to vim/vim, Subscribed

Me as a novice linux user. What do I do so that this issue is resolved in my computer.

Should I wait for the next release ?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10391/1121283885@github.com>

lacygoill

unread,
May 9, 2022, 12:13:55 PM5/9/22
to vim/vim, Subscribed

Should I wait for the next release ?

You need to wait for the next update of the runtime files. The latest one was pushed 2 days ago. The next one will probably happen in a few days or weeks.

From then, it depends on how you update your Vim version. For example, if you rely on the package manager of your OS, then you'll need to wait for the packaging of a more recent version.

If you want an immediate fix, try to run these shell commands:

$ curl --fail --location --show-error --silent --output $HOME/.vim/ftplugin/abaqus.vim https://raw.githubusercontent.com/vim/vim/master/runtime/ftplugin/abaqus.vim

$ sed -i '/let b:undo_ftplugin = "let s:cpo_save = &cpoptions|"/,/^$/s/s:/b:/g' /home/lgc/.vim/ftplugin/abaqus.vim

The first command copies the latest version of the abaqus filetype plugin in your home directory.
The second command applies the fix.

Your custom version of the filetype plugin will have priority over the default one, because – inside the runtimepath – your home config (~/.vim/) appears before the default one ($VIMRUNTIME).

The runtimepath is to Vim what $PATH is to the shell. See :help 'runtimepath'.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10391/1121301971@github.com>

lacygoill

unread,
May 9, 2022, 12:18:17 PM5/9/22
to vim/vim, Subscribed

If you want an immediate fix, try to run these shell commands:

Or execute these Ex commands:

:call mkdir($HOME . '/.vim/ftplugin/', 'p')
:edit $HOME/.vim/ftplugin/abaqus.vim
:read $VIMRUNTIME/ftplugin/abaqus.vim
:silent 90,94 substitute/s:/b:/
:write


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10391/1121306465@github.com>

Vasu Kolli

unread,
May 10, 2022, 3:09:44 AM5/10/22
to vim/vim, Subscribed

Thank you for your explanation. :)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/10391/1122011662@github.com>

ben.k...@gmail.com

unread,
May 10, 2022, 9:33:58 AM5/10/22
to vim_dev
The Ex commands seem superior, not least because they don't rely on unportable `sed -i` (cf. https://benknoble.github.io/blog/2020/08/06/stop-sed-i/). Why the `:silent` prefix to `:substitute`, though?
Reply all
Reply to author
Forward
0 new messages