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

Swap warning #7

Closed
tomaszwojcik opened this issue Oct 7, 2014 · 11 comments
Closed

Swap warning #7

tomaszwojcik opened this issue Oct 7, 2014 · 11 comments
Assignees

Comments

@tomaszwojcik
Copy link

Hello

I use MacTeX and Mac OS X Preview as my preview program.
When I start the :LLPStartPreview and save the file I get the following error:

"latex-test.tex" 10L, 207C written
Error detected while processing function <SNR>60_Compile:
line   10:
E768: Swap file exists: /Users/twojcik/.vim_tmp/latex-test.tex.swp (:silent! overrides)

I don't want to disable the swap.

@xuhdev
Copy link
Owner

xuhdev commented Oct 7, 2014

It should not happen though. Can you stop Vim and see whether the file still exists? The warning should come because there IS a file with a name of latex-test.tex.swp there.

@tomaszwojcik
Copy link
Author

I've tried that. After quitting Vim the swap file is erased.

@xuhdev xuhdev self-assigned this Oct 9, 2014
@xuhdev xuhdev added the bug label Oct 9, 2014
@xuhdev
Copy link
Owner

xuhdev commented Oct 9, 2014

I see the problem now. It's because you have set swp file to a specific directory, but the command to create a temp file also asks Vim to create the exact same file in that directory. This would not be a problem if you always have swp file in the same directory.

Anyway, this is a bug and I'm gonna fix it.

@xuhdev
Copy link
Owner

xuhdev commented Oct 9, 2014

Hold on -- seems this is a problem of your configuration or a bug in Vim. Can you post the part of configuration which you set the path of the swp file?

@tomaszwojcik
Copy link
Author

My tmp/backup config:

set backupdir=~/.vim_bck
set directory=~/.vim_tmp

@xuhdev
Copy link
Owner

xuhdev commented Oct 9, 2014

OK, the problem is found.

Open any file with Vim with your configuration, run the following command twice:

:write! /tmp/the_file_name.ext

You'll see the error message pops up. Because Vim thinks this file has a corresponding swp file. Seems this is a defect that Vim doesn't create a prefix for the swap files for files in different directories.

Try to add the following to your vimrc file and apply this patch. Let me know whether it works for you.

autocmd BufEnter *.tex  let b:livepreview_buf_data['tmp_src_file'] = '/tmp/my_name.tex'

@tomaszwojcik
Copy link
Author

After applying the patch and adding command to the vimrc I open any tex file and I get the following error:

Error detected while processing BufEnter Auto commands for "*.tex":
E121: Undefined variable: b:livepreview_buf_data

@tekhnus
Copy link

tekhnus commented Jan 10, 2015

Just add double slashes to paths in your config to avoid name collision:

set backupdir=~/.vim_bck//
set directory=~/.vim_tmp//

(This will prefix swap file names with abolute paths)

@nhooyr
Copy link

nhooyr commented Feb 5, 2016

harius's solution worked great for me.

@satvug
Copy link

satvug commented Jan 12, 2017

Your solution worked for me too, harius - thanks!

badouralix added a commit that referenced this issue Jul 19, 2017
Referencing #7 about E768
badouralix added a commit that referenced this issue Jul 19, 2017
Referencing #7 about E768
@badouralix
Copy link
Collaborator

As the name of the file written in the tmp dir is essential to make the plugin work on a multi files project, the only lasting solution is to use @Harius trick. I'm closing this issue after referencing it in the project readme. Feel free to re-open it whether something related happens.

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

No branches or pull requests

6 participants