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

Can't open file (win gvim) #48

Closed
hSATAC opened this issue Nov 21, 2011 · 35 comments
Closed

Can't open file (win gvim) #48

hSATAC opened this issue Nov 21, 2011 · 35 comments

Comments

@hSATAC
Copy link

hSATAC commented Nov 21, 2011

win vim, it worked fine.
but in gvim, when I tried to Gist
it said:

Posting it to gist...
Error detected while processing function gist#Gist..44_GistPost:
line 63:
E484: Can't open file C:\Users\Ash\AppData\Local\Temp\VIo24B.tmp

And I looked this file, it didn't exist.

I tried with existing file, unsaved new file, results are the same.

@mattn
Copy link
Owner

mattn commented Nov 21, 2011

Are you using gvim on cygwin? or %TEMP% is pointed on NFS volume?
I can't reproduce it.

@hSATAC
Copy link
Author

hSATAC commented Nov 21, 2011

I am using gvim.
my %TEMP% is pointed to C:\Users\Ash\AppData\Local\Temp
It's win 7 default value, I didn't change it.

Here's my gvim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 10 2011 22:01:52)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1-189
Compiled by Yongwei@Shanghai
Big version with GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff
+digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi
+file_in_path +find_in_path +float +folding -footer +gettext/dyn -hangul_input
+iconv/dyn +insert_expand +jumplist +keymap +langmap +libcall +linebreak
+lispindent +listcmds +localmap +lua/dyn +menu +mksession +modify_fname +mouse
+mouseshape +multi_byte_ime/dyn +multi_lang -mzscheme +netbeans_intg +ole
-osfiletype +path_extra +perl/dyn +persistent_undo -postscript +printer
-profile +python/dyn +python3/dyn +quickfix +reltime +rightleft +ruby/dyn
+scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop
+syntax +tag_binary +tag_old_static -tag_any_white +tcl/dyn -tgetent
-termresponse +textobjects +title +toolbar +user_commands +vertsplit
+virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu
+windows +writebackup -xfontset -xim -xterm_save +xpm_w32
system vimrc file: "$VIM\vimrc"
user vimrc file: "$HOME_vimrc"
2nd user vimrc file: "$VIM_vimrc"
user exrc file: "$HOME_exrc"
2nd user exrc file: "$VIM_exrc"
system gvimrc file: "$VIM\gvimrc"
user gvimrc file: "$HOME_gvimrc"
2nd user gvimrc file: "$VIM_gvimrc"
system menu file: "$VIMRUNTIME\menu.vim"
Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -DFEAT_CSCOPE
-DFEAT_NETBEANS_INTG -DFEAT_XPM_W32 -DWINVER=0x0400 -D_WIN32_WINNT=0x0400
/Fo.\ObjGOULYHTR/ /Wp64 /Ox -DNDEBUG /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME
-DGLOBAL_IME -DFEAT_MBYTE -DFEAT_GUI_W32 -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL

@mattn
Copy link
Owner

mattn commented Nov 21, 2011

Where is your curl.exe?
If you don't have which.exe, please try:

:echo findfile("curl.exe", substitute($PATH, ';', ',', 'g').";")

@hSATAC
Copy link
Author

hSATAC commented Nov 22, 2011

it's in the same folder with my git.exe

:echo findfile("curl.exe", substitute($PATH, ';', ',', 'g').";")

shows

\Users\Ash\Dropbox\Programs\git\bin\curl.exe

@mattn
Copy link
Owner

mattn commented Nov 22, 2011

You seens to use curl that is bundled in msysgit.
Probably, that can't treat backshash as path separator. You can get windows native curl.exe from http://curl.haxx.se/ .
And, I'll look into it later.

@hSATAC
Copy link
Author

hSATAC commented Nov 22, 2011

I tried the curl.exe from http://curl.haxx.se/ and results the same.

Thx for your quick reply.

@mattn
Copy link
Owner

mattn commented Nov 22, 2011

Hmm, where did you put curl.exe? please try to do again.

:echo findfile("curl.exe", substitute($PATH, ';', ',', 'g').";")

And it seems that you don't use latest gist-vim.
Please try following.

  1. open autoload/gist.vim in vim
  2. /s:GistPost
  3. 63j

What lines around can you see?

@hSATAC
Copy link
Author

hSATAC commented Nov 22, 2011

I put the downloaded curl.exe into c:\windows\system32\

:echo findfile("curl.exe", substitute($PATH, ';', ',', 'g').";")
shows:

\Windows\system32\curl.exe

and the above shows:

let res = system('curl -f -i '.g:gist_curl_options.' -d @'.quote.file.quote.' '.url)

@mattn
Copy link
Owner

mattn commented Nov 22, 2011

Hmm, do you set shell variable?
or, are you trying to run gvim.exe on bash on msys?

@hSATAC
Copy link
Author

hSATAC commented Nov 22, 2011

No, I don't think I set "shell" variable. Could you provide more information about it?
And I run gvim by simply double-click on gvim.exe

I did set the whole git\bin into my %PATH% because it told me it needs git command, is this relevant?

I can't find the tmp file gvim mentioned ex: VIoB1.tmp(I did a full harddrive find)

Could it be something about TMP or gvim itself?

@mattn
Copy link
Owner

mattn commented Nov 22, 2011

Please try 2 cases.

_how tempname() works._

start gvim.exe as usual.

:echo tempname()

check the file is exists.

_git/bin make this problem or not_

start cmd.exe

cd c:\path\to\gvim\
set PATH=.;
set TEMP=.
gvim.exe

then, type :echo tempname() and check the file is exists.

@hSATAC
Copy link
Author

hSATAC commented Nov 22, 2011

case 1:

C:\Users\Ash\AppData\Local\Temp\VIC18B0.tmp

And no, the file does not exist.

case 2:

C:\Users\Ash\AppData\Local\Temp\VIB1E88.tmp

And no, the file does not exist.
It's weird...

@hSATAC hSATAC closed this as completed Nov 22, 2011
@mattn
Copy link
Owner

mattn commented Nov 22, 2011

What value of TEMP and TMP? same?

@hSATAC hSATAC reopened this Nov 22, 2011
@hSATAC
Copy link
Author

hSATAC commented Nov 22, 2011

I tried to set TMP and tempname() now is

C:\Users\Ash\Dropbox\Programs\vim73\VIo7350.tmp

Then I add git into PATH and try to Gist

It still goes:

Posting it to gist...
Error detected while processing function gist#Gist..<SNR>44_GistPost:
line   63:
E484: Can't open file C:\Users\Ash\Dropbox\Programs\vim73\VIo7350.tmp

And still , this tmp file does not exist.

@mattn
Copy link
Owner

mattn commented Nov 22, 2011

hmm, how about upgrade of vim?

@mattn
Copy link
Owner

mattn commented Nov 30, 2011

If the TMP point another directory, how it works?

@hSATAC
Copy link
Author

hSATAC commented Nov 30, 2011

Tried the newest download package of gvim from vim.com, still the same.

Tried to point TMP to C:, still the same.

Guess I'll give windows up, go back to mac and linux...

Is this only me or all gvim on windows got this issue?
(I got this issue both on my office PC and home PC.)

Should I close this issue if there's no one else but me?

@mattn
Copy link
Owner

mattn commented Nov 30, 2011

Should I close this issue if there's no one else but me?

OK. Sorry for long time & Thanks.

@hSATAC
Copy link
Author

hSATAC commented Nov 30, 2011

nope, thx for ur help and great plugin :)

@hSATAC hSATAC closed this as completed Nov 30, 2011
@philgoetz
Copy link

I'm having a similar problem on Windows 7:

Error detected while processing C:\bin\files\edit\Vim\vim73\ftplugin\perl.vim:
line 50:
E484: Can't open file C:/bin/os/cygwin/tmp/VIoA97.tmp
Error detected while processing function 6_LoadFTPlugin:
line 17:
E170: Missing :endfor
Error detected while processing function 2_FTpl:
line 10:
E171: Missing :endif

I bet this is one of those wacky Win 7 directory protection problems. The temp file isn't there because it's a temp file; vim is trying to CREATE it, not read it. I'm trying to run gvim from cygwin, so the user account whose privs are being checked may be the application's instead of my own.

Win 7 permissions flat-out don't work. First, there's a bug with "read-only". Most directories on a Win 7 system (including this tmp directory) will get a "read-only" bit set. There is no way to unset it. You can use the "properties" window and uncheck a box and hit "apply", and it is SUPPOSED to unset the read-only bit, but it does not. Microsoft is aware of the problem and doesn't care. Their official answer, IIRC, is: The "read-only bit" is not what the OS checks to determine whether it can write to a directory. It's a bit that is returned to applications if they ask the OS in a certain way whether a directory is read-only. Very few applications do this; therefore, we don't care and won't fix it.

Second, the permissions don't work. I have thousands of directories on my Win7 machine where the permissions are set so the current user has full control, but the current user still isn't allowed to write to the directory. Sometimes this involves symlinks, which basically don't work, and report the permissions and ownership and so on incorrectly, and inherit them in mysterious ways.

@dbeusee
Copy link

dbeusee commented Jan 30, 2013

This is not a permissions problem, and windows DOES in fact unset read-only. It's just a GUI bug that it thinks the bit is set. If you don't believe me, bring up the command prompt, cd to where the folder is, then do: dir /a:r. The folder you turned read-only off will not appear, because it really IS off.

The problem is really with the system() call. Just doing this from within vim will reproduce it:
:echo system("echo hi")

The problem is because some shell like cygwin shell is being used. I put these commands at the top of my _vimrc file to solve the problem:
set shell=cmd
set shellcmdflag=/c

This problem is solved now. I am not certain why this fixes it, because it seems like a race condition where the tmp file is created and closed before the process is done using it. The tmp file is in fact created successfully (I saw this with procmon), but it is closed/deleted before it's truely done with it.

@asgeo1
Copy link

asgeo1 commented May 21, 2013

@dbeusee - thank you! That worked a treat!

@philgoetz
Copy link

Wow! It works! I salute you.

@rwxrob
Copy link

rwxrob commented Jan 28, 2014

I know it seems like a hopeless cause, but Windows 8 has changed something to stop this fix from working when using git-bash that comes from git-scm.org. I'm trying as many possible combinations as I can but the :echo system("echo hi") still consistently throws the same E483: Can't get temp file name. This makes me very gun shy with anything involving system().

@mattn
Copy link
Owner

mattn commented Jan 28, 2014

What your configuration?

set shell?
set shellslash?

@rwxrob
Copy link

rwxrob commented Feb 14, 2014

The fix for me was simply making sure /c/Program Files (x86)/Git/bin was in my $PATH in my .bashrc so that my set shell=bash worked (along with a let $TMP="/tmp"). Not only did this fix the problems when opening stuff that used system() it allowed me to use the shell-out filters I have.

@mattn
Copy link
Owner

mattn commented Feb 15, 2014

@robmuh Still have problem?

@torbatamas
Copy link

@dbeusee 's sloution worked for me too!

@hginzel
Copy link

hginzel commented Nov 9, 2016

When I run gVim (portable, 7.4) from bash (included in Git for Windows) (v2.8.3) (GNU bash, version 4.3.42(5)-release (x86_64-pc-msys)) I get in discussed problem. The shell option is C:\Program Files\Git\usr\bin\bash.

Based on this issue, I have set in C:\PortableApps\gVimPortable\Data\settings\_vimrc:

if &shell =~ '\\bash$'
  set shell=bash shellcmdflag=-c
endif

Seems working. Thank you. There is no other bash installed.

@mattn
Copy link
Owner

mattn commented Nov 9, 2016

If you change shell and shellcmdflag, you need to change shellxquote too.

@hginzel
Copy link

hginzel commented Nov 9, 2016

Variables shellquote and shellxquote were empty. I am leaving them empty. Seems working. When I try :!ls $TMP I see in the "vimrun" terminal window that gvim executes bash -c "ls $TMP". Someone (gVim?, vimrun?) is putting quotes around.

@mattn
Copy link
Owner

mattn commented Nov 9, 2016

Ah, if your shellquote and shellxquote is empty, it is the problem that contain spaces in the command filename as your said.

@hginzel
Copy link

hginzel commented Nov 9, 2016

I am sorry, I don't exactly understand. To which value should I set which of shellquote or shellxquote variable? E.g. when I set shellxquote to " and I don't set the shell variable, I get

C:\Program Files\Git\usr\bin\bash -c "ls $TMPDIR"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

When I set shell=bash shellcmdflag=-c shellquote= shellxquote=' and run :!ls "C:\Program Files" I get the list. But when I run :!ls "C:\Program Files" >a file a is not created.

What are the correct settings, please? Which shell should be used (bash or cmd)? Does vimrun.exe also some "unquoting"? Why doesn't gVim set the variables correctly by default? Where should be what changed, please?

It seems that only working solution with redirecting working is set shell=cmd shellcmdflag=/c shellquote= shellxquote=(. Is there a solution with shell=bash and redirecting working, please?

Thank you in advance.

@mattn
Copy link
Owner

mattn commented Nov 9, 2016

This is simply problem about executing shell command. Maybe you can solve with set shell=c:/progra~1/git/usr/bin/bash

@hginzel
Copy link

hginzel commented Nov 10, 2016

I have already solved the space in shell file name setting shell=bash, because is in PATH and is only one installed. Another solution is feature/pull request to Vim author (Bram) to handle spaces in shell variable.

Other shell* variables must I not set, because Vim has already set them as described in :help'shellxquote'. Based on :helpdos-shell these should be set shell=bash shellquote= shellxquote=\" if you want to use bash as a shell under Windows. But then is necessary to use unix file notation

!ls C:/PortableApps >a
!ls C:/Program\ Files >a
!ls 'C:/Program Files' >a

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

8 participants