Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:20:13+00:00 2026-06-02T06:20:13+00:00

I was playing with some ruby the other day and I wrote the following

  • 0

I was playing with some ruby the other day and I wrote the following code

 File.open(my_file, "w+") do | fh | 
     begin
       fh.readonly = true               <--------Exception thrown here
     ensure
       fh.close
     end
  end

this does not work as it throws EACCES because the file is readonly, if I change the open flag to “r” this works just fine. To me this is counter intuitive because I thought opening it with “r” meant i’d only be able to read the file, not change attributes.

I am using win32-file (0.6.6) with ruby 1.8.7 (not upgradable for current project), is this normal behaviour a quirk of the win-32 file gem or just a bug that I am able to code around.

In order to set the readonly bit to true I must open with w+ which seems much more sensible

A bit more info is that this test was performed on Windows Server 2003 64-bit, just in case that makes a diff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:20:16+00:00Added an answer on June 2, 2026 at 6:20 am

    I eventually found out what this was, there was another process locking the directory with an exclusive lock on the filesystem, It didn’t show up with processexplorer but i noticed in my log something logging that directory, I stopped the service and bam it worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm playing around with Ruby to do some file versioning for me. I have
I'm playing with some Data Parallel Haskell code and found myself in need of
i'm building an iphone application that base on playing some audio file. all thing
I'm new to Ruby and I've been playing around with making some webapps with
I'm playing with Ruby EventMachines for some time now and I think I'm understandings
i've been playing some time with different builds of my application and there seem
Been doing some playing call my service which is on a different domain using
I've been playing with some algorithms on the internet for a while and I
I've been playing with some of the MVC tutorials on making a database website
I am trying to set up an Android emulator to do some playing around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.