Skip to content

Add a warning for when the history path doesn't exist - #852

Merged
st0012 merged 4 commits into
ruby:masterfrom
ignacio-chiazzo:add-warning
Feb 2, 2024
Merged

st0012 merged 4 commits into
ruby:masterfrom
ignacio-chiazzo:add-warning

Conversation

@ignacio-chiazzo

@ignacio-chiazzo ignacio-chiazzo commented Jan 31, 2024 •

Copy link
Copy Markdown
Contributor

When using a file path that doesn't exist in the IRB.conf[:HISTORY_FILE] env variable, IRB creates a new file with that directory without warning the developer.

This PR prints a warning when that happens.

➜  irb git:(add-warning) ✗ echo 'IRB.conf[:HISTORY_FILE] = "/Users/ignaciochiazzo/irb/test/irb/fake-folder/fake/testing.rb"' > ~/.irbrc

➜  irb git:(add-warning) ✗ bundle exec irb
irb(main):001> a = 1
=> 1
irb(main):002> exit
Warning: The path to save IRB history does not exist. Please, set the env var IRB.conf[:HISTORY_FILE] with a valid path. 

#830

Demo

Screen.Recording.2024-02-02.at.4.31.29.PM.mov

@st0012

st0012 commented Jan 31, 2024

Copy link
Copy Markdown
Member

Can you add a test case to IRBHistoryIntegrationTest?

@st0012

st0012 commented Jan 31, 2024

Copy link
Copy Markdown
Member

Also, I don't think HISTORY_FILE env var would be picked up by IRB. Are you sure the example is working? Maybe you also set the path in .irbrc?

@tompng

tompng commented Feb 1, 2024 •

Copy link
Copy Markdown
Member

Issue #830 is for no such directory case. Not the case that directory exists and history file does not exist.

Comment thread lib/irb/history.rb Resolved
Comment thread lib/irb/history.rb Resolved
Comment thread lib/irb/history.rb Resolved

@st0012 st0012 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much 👍

@st0012 st0012 added the bug Something isn't working label Feb 2, 2024
@st0012
st0012 merged commit 9e6fa67 into ruby:master Feb 2, 2024
matzbot pushed a commit to ruby/ruby that referenced this pull request Feb 2, 2024
(ruby/irb#852)

* Add a warning for when the history path doesn't exist

* warn when the directory does not exist

* added test for when the history_file does not exist

* Update lib/irb/history.rb

---------

ruby/irb@9e6fa67212

Co-authored-by: Stan Lo <stan001212@gmail.com>
@st0012 st0012 mentioned this pull request Feb 2, 2024
@nobu

nobu commented Feb 3, 2024 •

Copy link
Copy Markdown
Member

This causes a warning in ruby/ruby:

Warning: The directory to save IRB's history file does not exist. Please double check `IRB.conf[:HISTORY_FILE]`'s value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants