# (unknown)

**URL:** <https://rubytalk.org/t/unknown/46151>\
**Category:** ruby-talk\
**Created:** [27 April 2008 17:39 UTC](https://rubytalk.org/t/unknown/46151 "2008-04-27T17:39:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Smith1](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@Dave\_Smith1](https://rubytalk.org/u/Dave_Smith1)\
**Post date:** [27 April 2008 17:39 UTC](https://rubytalk.org/t/unknown/46151/1 "2008-04-27T17:39:45Z")

</div>

I'm trying to use win32/file to set permission on a file, but I can't seem  
to get it working. Here's what I've tried

require "win32/file"  
File.set\_permissions("C:\\foo.txt", {"Domain\\username" =\> 2032127})

and I get this error

:/ruby/lib/ruby/gems/1.8/gems/win32-file-0.5.5/lib/win32/file.rb:212:in  
`set\_permissions': The access control list (ACL) structure is invalid.  
(ArgumentError)

I can read permissions I just can't set them.

---

<div class="post-metadata">

**Author:** ![Heesob\_Park](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@Heesob\_Park](https://rubytalk.org/u/Heesob_Park)\
**Post date:** [28 April 2008 02:10 UTC](https://rubytalk.org/t/unknown/46151/2 "2008-04-28T02:10:07Z")

</div>

Hi,

Dave Smith wrote:

> I'm trying to use win32/file to set permission on a file, but I can't  
> seem  
> to get it working. Here's what I've tried
> 
> require "win32/file"  
> File.set\_permissions("C:\\foo.txt", {"Domain\\username" =\> 2032127})
> 
> and I get this error
> 
> :/ruby/lib/ruby/gems/1.8/gems/win32-file-0.5.5/lib/win32/file.rb:212:in  
> `set\_permissions': The access control list (ACL) structure is invalid.  
> (ArgumentError)

In the current version, it means the given account do not exist.  
The misleading message must be modified.

Inserting the following line at file.rb #158 will solve this problem.

if sid.strip == ""  
&nbsp;&nbsp;raise ArgumentError, 'Account does not exist'  
end

> I can read permissions I just can't set them.

Try this:

perm = File.get\_permissions("C:\\foo.txt")  
p perm  
File.set\_permissions("C:\\foo.txt",perm)

Regards,  
Park Heesob

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
