ruby / ruby/irb

Can't write history on irb exit on Windows

Open
#1,219 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
478
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
12

Description

On my Windows machine, as of ruby 3.4.9 irb 1.14.3, the irb can no longer write history on exit and shows the following warning:

Can't write history to "..." due to insufficient permissions.

I can write manually into the same history file from within irb just fine. The "problem" seems to be caused by the changes in 52307f9. I first suspected history_file.chmod 0o600 failing on Windows, but it is actually history_file.dirname.writable? that returns false, despite I am able to write files from irb into my user profile directory just fine.

Saving history worked correctly in ruby 3.3.11 irb 1.13.1, probably because it simply did not have the directory writable check back then.

The .writable? check seems to work correctly for other directories but returns false for the user profile in both ruby versions. I am not sure why, I checked the permissions and they look fine. As mentioned, the actual files can be written without any problems.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the IRB history-saving path that checks history_file.dirname.writable? and compare it with the behavior in IRB 1.13.1 and 1.14.3 on Windows. Reproduce the warning using a user profile history file, then verify that exiting IRB saves history without the incorrect permissions warning while other directory checks remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.