# Chmod on Windoze

**URL:** <https://rubytalk.org/t/chmod-on-windoze/21258>\
**Category:** ruby-talk\
**Created:** [2 October 2005 04:56 UTC](https://rubytalk.org/t/chmod-on-windoze/21258 "2005-10-02T04:56:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip5](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@Phlip5](https://rubytalk.org/u/Phlip5)\
**Post date:** [2 October 2005 04:56 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/1 "2005-10-02T04:56:45Z")

</div>

Rubies:

I'm aware the answer is "because MS Windows is inferior", and I certainly  
have no intention of besmirching Ruby, but...

Why does File.chmod() only work on GNU / Un\*x? Why does it punt on Windows?  
Has someone fixed this since last I checked? Shelling to ATTRIB is icky.

CygWin doesn't have this \>cough\< problem...

> **···**
>
> --  
> &nbsp;&nbsp;Phlip  
> &nbsp;&nbsp;[http://www.greencheese.org/ZeekLand](http://www.greencheese.org/ZeekLand) \<-- NOT a blog!!!

---

<div class="post-metadata">

**Author:** ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)\
**Post date:** [2 October 2005 05:11 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/2 "2005-10-02T05:11:46Z")

</div>

Phlip wrote:

> Rubies:
> 
> I'm aware the answer is "because MS Windows is inferior", and I certainly  
> have no intention of besmirching Ruby, but...
> 
> Why does File.chmod() only work on GNU / Un\*x? Why does it punt on Windows?  
> Has someone fixed this since last I checked? Shelling to ATTRIB is icky.
> 
> CygWin doesn't have this \>cough\< problem...

Why can't I do CreateProcess() on Unix? Windows doesn't have this  
problem.

Seriously, MS Windows just doesn't do permissions the way Unix does,  
though it does have the equivalent of ACL that most flavors of Unix  
have. See win32-file if you want to tinker with it.

Oh, and actually, File.chmod \*does\* work on Windows...kinda. You can  
use 0444 to make a file read-only, or 0644 to make it writeable (or  
rather, to make it not read-only). You can do trickier things with  
win32-file.

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![Phlip5](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@Phlip5](https://rubytalk.org/u/Phlip5)\
**Post date:** [2 October 2005 05:41 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/3 "2005-10-02T05:41:45Z")

</div>

Daniel Berger wrote:

> Why can't I do CreateProcess() on Unix? Windows doesn't have this  
> problem.

I stopped reading here.

> **···**
>
> --  
> &nbsp;&nbsp;Phlip  
> &nbsp;&nbsp;[greencheese.org](http://www.greencheese.org/ZeekLand) \<-- NOT a blog!!!

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello1](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@Martin\_DeMello1](https://rubytalk.org/u/Martin_DeMello1)\
**Post date:** [2 October 2005 09:26 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/4 "2005-10-02T09:26:46Z")

</div>

Your loss - he answered your question downstream.

martin

> **···**
>
> Phlip \<phlipcpp@yahoo.com\> wrote:
> 
> > Daniel Berger wrote:
> > 
> > \> Why can't I do CreateProcess() on Unix? Windows doesn't have this  
> > \> problem.
> > 
> > I stopped reading here.

---

<div class="post-metadata">

**Author:** ![James\_Britt4](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@James\_Britt4](https://rubytalk.org/u/James_Britt4)\
**Post date:** [2 October 2005 13:00 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/5 "2005-10-02T13:00:24Z")

</div>

Martin DeMello wrote:

> **···**
>
> > Phlip \<phlipcpp@yahoo.com\> wrote:
> > 
> > > Daniel Berger wrote:
> > > 
> > > > Why can't I do CreateProcess() on Unix? Windows doesn't have this  
> > > > problem.
> > > 
> > > I stopped reading here.
> > 
> > Your loss - he answered your question downstream.
> 
> I'd venture to guess that if someone is looking is looking for help with some tool or application or OS, using /. script-kiddie slang, such as "Windoze", or beginning a request for help by knocking the subject matter, is probably not the best way to encourage those who may know the answer to pitch in.
> 
> James
> 
> --
> 
> [http://www.ruby-doc.org](http://www.ruby-doc.org) - The Ruby Documentation Site  
> [http://www.rubyxml.com](http://www.rubyxml.com) - News, Articles, and Listings for Ruby & XML  
> [http://www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff  
> [http://www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys

---

<div class="post-metadata">

**Author:** ![Phlip5](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@Phlip5](https://rubytalk.org/u/Phlip5)\
**Post date:** [2 October 2005 16:36 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/6 "2005-10-02T16:36:46Z")

</div>

James Britt wrote:

> I'd venture to guess that if someone is looking is looking for help with  
> some tool or application or OS, using /. script-kiddie slang, such as  
> "Windoze", or beginning a request for help by knocking the subject matter,  
> is probably not the best way to encourage those who may know the answer to  
> pitch in.

So "you asked a stupid question, so you deserve to get flamed". Okay.

(For those curious about the actual topics, 0444 and 0644 started working,  
so I don't know why historically they did not for me. And CreateProcess()  
and fork() are sufficiently different that one should not be expected to  
emulate the other...)

> **···**
>
> --  
> &nbsp;&nbsp;Phlip  
> &nbsp;&nbsp;[greencheese.org](http://www.greencheese.org/ZeekLand) \<-- NOT a blog!!!

---

<div class="post-metadata">

**Author:** ![Matthew\_Desmarais1](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@Matthew\_Desmarais1](https://rubytalk.org/u/Matthew_Desmarais1)\
**Post date:** [2 October 2005 16:56 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/7 "2005-10-02T16:56:36Z")

</div>

> James Britt wrote:
> 
> > I'd venture to guess that if someone is looking is looking for help with  
> > some tool or application or OS, using /. script-kiddie slang, such as  
> > "Windoze", or beginning a request for help by knocking the subject  
> > matter,  
> > is probably not the best way to encourage those who may know the answer  
> > to  
> > pitch in.
> 
> So "you asked a stupid question, so you deserve to get flamed". Okay.
> 
> (For those curious about the actual topics, 0444 and 0644 started working,  
> so I don't know why historically they did not for me. And CreateProcess()  
> and fork() are sufficiently different that one should not be expected to  
> emulate the other...)
> 
> --  
> &nbsp;&nbsp;Phlip  
> &nbsp;&nbsp;[greencheese.org](http://www.greencheese.org/ZeekLand) \<-- NOT a blog!!!

But really though, thanks Daniel for your prompt, accurate (to the best of  
\_my\_ knowledge) and sincere answer to a question that is difficult to ask  
correctly, nevermind answer.

Can we flesh this out just a little bit more though? The impression that  
I've always gotten is that it isn't really possible to map across from the  
Unix permission mechanism to the one implemented on Windows. The bits  
that you set when you chmod something don't really translate directly into  
some of the more complex permissions that you can set on Windows systems,  
right?

So I don't think that Ruby (or anybody else) can hope to have a permission  
handling aspect that is both cross-platform and correct. Am I wrong?

---

<div class="post-metadata">

**Author:** ![James\_Britt4](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@James\_Britt4](https://rubytalk.org/u/James_Britt4)\
**Post date:** [2 October 2005 17:24 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/8 "2005-10-02T17:24:22Z")

</div>

Phlip wrote:

> James Britt wrote:
> 
> > I'd venture to guess that if someone is looking is looking for help with some tool or application or OS, using /. script-kiddie slang, such as "Windoze", or beginning a request for help by knocking the subject matter, is probably not the best way to encourage those who may know the answer to pitch in.
> 
> So "you asked a stupid question, so you deserve to get flamed". Okay.

Well, the question itself was a good one.

I spend a lot of time working on Windows, and have picked up assorted knowledge and tips, but I'm likely not going to be overly interested in sharing this info with someone who is dismissive of the platform right from the get-go. It suggests, perhaps incorrectly, that the questioner really isn't serious, and hasn't bothered to do some basic groundwork because the topic is beneath them.

For example, if I had a question about something on a Mac, and I asked questions about Crapintosh or Hackintosh or Crapple computers, I'd deserve to be ignored or flamed.

James

> **···**
>
> --
> 
> [http://www.ruby-doc.org](http://www.ruby-doc.org) - The Ruby Documentation Site  
> [http://www.rubyxml.com](http://www.rubyxml.com) - News, Articles, and Listings for Ruby & XML  
> [http://www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff  
> [http://www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys

---

<div class="post-metadata">

**Author:** ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)\
**Post date:** [2 October 2005 21:21 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/9 "2005-10-02T21:21:46Z")

</div>

ogilthorpe@davie.textdrive.com wrote:

\<snip\>

> Can we flesh this out just a little bit more though? The impression that  
> I've always gotten is that it isn't really possible to map across from the  
> Unix permission mechanism to the one implemented on Windows. The bits  
> that you set when you chmod something don't really translate directly into  
> some of the more complex permissions that you can set on Windows systems,  
> right?

Correct. For whatever reason MS decided to support a limited form of  
chmod where you could make a file read-only, which probably just calls  
SetFileAttributes() behind the scenes. I'm not sure why they did this,  
other than to try to be more \*nix compatible. In the end I think it  
just confuses people.

> So I don't think that Ruby (or anybody else) can hope to have a permission  
> handling aspect that is both cross-platform and correct. Am I wrong?

No, you're not wrong.

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![Phlip5](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@Phlip5](https://rubytalk.org/u/Phlip5)\
**Post date:** [2 October 2005 21:46 UTC](https://rubytalk.org/t/chmod-on-windoze/21258/10 "2005-10-02T21:46:48Z")

</div>

James Britt wrote:

> For example, if I had a question about something on a Mac, and I asked  
> questions about Crapintosh or Hackintosh or Crapple computers, I'd deserve  
> to be ignored or flamed.

Mr Manners reminds the Gentle Poster that, given a choice between  
undeservedly flaming MS or deservedly the topic of this newsgroup, the  
original poster chose to make a joke of the dilemma...

Back on subject, MS didn't write File.chmod(). CygWin's chmod system  
apparently covers this by leaping into the NTFS Access Control Lists. I'm  
not claiming Ruby should bother; I just accidentally thought it was having  
trouble with the read-only bit.

> **···**
>
> --  
> &nbsp;&nbsp;Phlip  
> &nbsp;&nbsp;[greencheese.org](http://www.greencheese.org/ZeekLand) \<-- NOT a blog!!!
