Comments (18)
This problem is occurring because the 'Start In' field is blank in the
shortcuts in the Start menu. When a value isn't specified for that field, the
program that is started will use the working directory of the parent process.
The working directory is C:\Windows\system32 for the Start menu.
As a temporary workaround, you can edit each Vim icon in your Start menu and
add "%HOMEDRIVE%%HOMEPATH%" to the Start In field. This will ensure that Vim
starts with the working directory set to the home directory of the user who
started the program. The %HOMEDRIVE% variable will expand to something like C:
and %HOMEPATH% to \Users\Username where Username is the user who launched the
process. This is the same method used when launching the command prompt from
the start menu, for example.
For a permanent solution, line 1778 of src/dosinst.c needs to be changed to
#define WORKDIR "%HOMEDRIVE%%HOMEPATH%"
so that the value is set when the shortcuts are installed to the Start menu.
Original comment by [email protected]
on 6 Nov 2013 at 6:04
from vim.
I also found a solution that seems to work for all of the windows 7 gvim74
utilities.
In the C:\Program Files (x86)\Vim\vim74\mswin.vim file I inserted this command
after the " Last change: 2012 Jul 25
(line 5)
set directory+=%TEMP%
Now when I open gvim as any user, :set directory? shows
directory=.,c:\tmp,c:\temp,~\AppData\Local\Temp
which is writable, and does not ignore my "start in" settings for the icon when
opened from the desktop or the start menu. I still modify the "start in"
shortcut attribute to %HOMEDRIVE%%HOMEPATH%, just so I am not in
c:\windows\system32 when opening a new document.
The downside, is remembering this setting until a writable directory is the
default installer setting for gVim.
Original comment by [email protected]
on 5 Oct 2014 at 10:09
from vim.
As you can see from the "compiled by" line, that Vim version is about one year
old, which, for a Vim executable, is quite old.
Try repeating the experiment with the latest Vim (or gvim) 7.3.346 as can be
downloaded in the form of a Windows self-installer from
http://sourceforge.net/projects/cream/files/Vim/
Notes:
1. IIUC you should run the installer with sysadmin privileges).
2. This Vim distribution is found on the Cream _site_ but it is not the Cream _product_. Among Vim old-timers, it is known under the nickname "Vim without Cream".
Original comment by [email protected]
on 21 Oct 2011 at 9:06
from vim.
I have now downloaded 7.3.346 for the purpose of trying to reproduce the
problem. I was able to reproduce the problem in 7.3.346 also.
Out of curiosity, when you characterize 7.3.46 as quite old, that leads me to
ask, is there a newer general release for Win32? I was under the impression
that 7.3.46 was it, because it links from "http://www.vim.org/download.php#pc".
Cheers!
Original comment by metaed
on 21 Oct 2011 at 9:37
from vim.
New releases (with precompiled Windows binaries) rarely appear on www.vim.org
unless there is, well, a new release: the next one will probably be Vim 7.4, or
Vim 8.0 if there is no Vim 7.4. In the meantime, the Vim source is continuously
updated on Vim's public Mercurial repository, and Steve Hall (manager of the
Cream site) maintains an unofficial but fairly up-to-date Vim distribution
compiled for Windows with rarely more than a week's delay on the latest
sources; that distribution also includes the latest version of the runtime
files known at compile-time.
Original comment by [email protected]
on 22 Oct 2011 at 8:48
from vim.
[deleted comment]
from vim.
I was just upgraded to Windows 7 at work and ran into this issue.
The problem is that Vim defaults the 'directory' option to ".,C:\TMP,C:\Temp"
but these directories either do not exist or are not writeable.
Vim should instead use the $TMP and $TEMP environment variables instead of
hard-coded paths.
For now I have a workaround for the problem in my .vimrc like this:
http://cfc.kizzx2.com/index.php/gvim-e303-unable-to-open-swap-file-for-no-name-r
ecovery-impossible/
Original comment by [email protected]
on 15 Feb 2013 at 7:45
from vim.
I just installed vim 7.4 and the problem remains.
The solution:
In vmrc, the following lines exists by default,in lines 14 y 24 I use " instead
single quotes where exists < or >.
This appeared to be related to escape correctly.
Escuse my English.
1 set diffexpr=MyDiff()
2 function MyDiff()
3 let opt = '-a --binary '
4 if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
5 if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
6 let arg1 = v:fname_in
7 if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
8 let arg2 = v:fname_new
9 if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
10 let arg3 = v:fname_out
11 if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
12 let eq = ''
13 if $VIMRUNTIME =~ ' '
14 if &sh =~ "\<cmd"
15 let cmd = '""' . $VIMRUNTIME . '\diff"'
16 let eq = '"'
17 else
18 let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
19 endif
20 else
21 let cmd = $VIMRUNTIME . '\diff'
22 endif
23 silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . " > " . arg3 . eq
24 endfunction
Original comment by [email protected]
on 11 Aug 2013 at 3:46
from vim.
I do not see the problem "out of the box".
Starting gVim from the desktop results in a swap file
"c:\Users\bram\Desktop\_.swp".
How did you start gVim then?
How did you manage to start in a directory that is not writable?
Original comment by [email protected]
on 11 Aug 2013 at 5:51
from vim.
Starting Vim from the start menu (which admittedly I've never done in 15+years
using it until just now) sets the current working directory to
C:\Windows\system32, which is not writeable to normal users, thus giving the
swap file error. It's not a common usage scenario, but the fix is pretty
simple.
The root issue is that neither C:\TMP and C:\Temp exist by default on Windows
and haven't for a long time, so the swap file fails in any folder that the user
can't write to. The default value of directory on Win32 should probably be
".,$TMP,$TEMP" (or maybe ".,C:\TMP,C:\Temp,$TMP,$TEMP" for maximum backwards
compatibility with older versions of Windows. I'm not sure when exactly the
change of temp dirs happened).
Original comment by [email protected]
on 20 Sep 2013 at 5:43
from vim.
[deleted comment]
from vim.
The trigger may be that the current directory is not writable...but when the
current directory is not writable, Vim has BAD fallback locations defined. It
should fall back to the environment variables %TEMP% or %TMP% but instead falls
back to C:\TEMP and C:\TMP which don't exist on Windows 7. As discussed earlier.
Original comment by [email protected]
on 6 Nov 2013 at 6:27
from vim.
This patch will use environment variables for the temp directories for both
'directory' and 'backupdir' options. This way on a fresh Windows 7 install, the
user should always have write access to at least one of the directories in
these options. This is needed even after the change to the installer "start in"
path in patch 7.4.077, because you can still start Vim from non-writable
directories.
Original comment by [email protected]
on 14 Nov 2013 at 4:38
Attachments:
from vim.
I'm hitting this on a relatively new Windows 7 install: anything that requires
Vim to use temporary files (diff, shell commands) results in undesirable
behaviour (E483 Can't get temp file name, or a diff that fails to highlight
differences).
I've tried
* setting my environment variables
* including let $TMP="c:\temp" & let $TEMP="c:\temp" in my _vimrc
* disabling UAC & rebooting
* setting broad access permissions on the Vim install folder
* changing the 'Start in' directory of the Vim shortcut icon (to My Documents)
* including set directory=.,$TMP,$TEMP in my _vimrc
All to no avail I'm afraid. Not sure how else I can tell Vim to locate the
temp files.
Original comment by [email protected]
on 21 Feb 2014 at 10:38
from vim.
If you do this (all by itself with no other changes) in your _vimrc, and your
_vimrc is getting sourced, then it should work for you:
set directory=.,$TMP,$TEMP
But you say this does not work? What does ":verbose set dir?" tell you? It
should point to expanded directory names. Note that C:\TEMP and C:\TMP do not
exist on a default Windows 7 install, so if you still had the manual setting of
$TEMP and $TMP in your _vimrc when you set your directory, that would have
failed.
Also, have you tried installing a Vim version >= 7.4.112? That is the version
which fixed this particular issue (by making the defaults for 'dir' and 'bdir'
include the temp directories).
Original comment by [email protected]
on 21 Feb 2014 at 6:57
from vim.
Actually, you might have a different issue. Does your _vimrc change the
settings for 'shell', 'shellxquote', and/or 'shellcmdflag'? Vim's quoting
behavior on Windows changed significantly between 7.3 and 7.4, so that old
workarounds for the atrocious quoting rules in the cmd.exe shell no longer work
and will cause errors like not being able to read temp files or not being able
to view diffs.
Original comment by [email protected]
on 21 Feb 2014 at 6:59
from vim.
With apologies to fritz... for the slow reply, installing version 7.4.103 from
the Cream Sourceforge repository appears to resolve my issues.
Original comment by [email protected]
on 27 Feb 2014 at 8:58
from vim.
Fixed by 7.4.112
Original comment by [email protected]
on 30 Sep 2014 at 9:23
- Changed state: Fixed
from vim.
Related Issues (20)
- command-block limitations HOT 6
- Any plans for delivering complete_info(["inserted"])? HOT 1
- VIM9: vimrc in vim9script gives E1072 for "&t_Co > 2" HOT 5
- --prefix dont work HOT 4
- getcompletion() from script throws unexpected error HOT 2
- msgfmt usage in configure.ac is inconsistent, breaks Solaris build HOT 2
- No completion for 'helplang' option HOT 6
- More scalable approach to merging changes into Vim HOT 6
- E340 + E341 Internal Error HOT 3
- configure error about ncurse lib HOT 6
- `interpolated string` has inconsistent handling of containers HOT 3
- [vim9script] unexpected error accessing items imported through symbolic linked directory HOT 5
- The behavior when specifying 2 for `setcellwidths` is different between the GUI version and the CUI version.
- Add multiple Sessionx support HOT 8
- 'gvim --remote' erroneously changes the current directory when the 'shellslash' option is enabled HOT 4
- runtime directories autoload/cargo and autoload/rust are missing from Makefile output
- [vim9script] add `test_override('defcompile', 1)` option
- .astro file extension is not recognised HOT 1
- Error detected while processing... when startup vim with -u option HOT 2
- gvimrc is not sourced from `~/.config/vim/` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim.