Issue #13151 has been reported by Thorsten Schning.

----------------------------------------
Bug #13151: File.writable? doesn't report correctly if a directory is writable on Windows.
https://bugs.ruby-lang.org/issues/13151

* Author: Thorsten Schning
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [i386-mingw32]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
I've tried installing a gem per user using a 64 Bit version of Ruby for Windows and recognized that this failed because of permission errors. Ruby wanted to write the successfully downloaded gem to a system wide cache dir and failed because of missing permissions in that directly by default. I've reported the problem to rubygems and during investigation of the problem we recognized that File.writable? doesn't provide the correct information about if the target dir is writable or not under Windows. File.writable? ultimately checks using eaccess and access and Microsoft says the following about the latter:

> When used with directories, _access determines only whether the specified directory exists; in Windows 2000 and later operating systems, all directories have read and write access.

https://msdn.microsoft.com/en-us/library/1w06ktdy.aspx

Because of the false return value, the downloaded gem is tried to be copied to the system wide cache dir and that fails. With win32-file there's a gem available which implements the correct check, because if that is required per user installation of a gem succeeds without even trying to copy anything system wide. The full story is on GitHub:

https://github.com/rubygems/rubygems/issues/1784#issuecomment-274508768



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>