Skip to content

Commit 7061b06

Browse files
Lazily require readline
The current implementation of readline has issues under Windows, and those issues prevent thor from being used. For example, in our bundler Windows CI, we had to patch `rb-readline` to workaround some issues because `rb-readline` (the default `readline` provider on Windows) couldn't be required. Moreover, we still get some issues when requiring `rb-readline` like ``` HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory ``` Since in some situations the part of thor using `readline` (`Thor::LineEditor`) is not required, for example, in most of CI situations. I thought it could be a good idea to lazily require `readline`.
1 parent 7f41bdc commit 7061b06

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/thor/line_editor/readline.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
begin
2-
require "readline"
3-
rescue LoadError
4-
end
5-
61
class Thor
72
module LineEditor
83
class Readline < Basic
94
def self.available?
5+
begin
6+
require "readline"
7+
rescue LoadError
8+
end
9+
1010
Object.const_defined?(:Readline)
1111
end
1212

0 commit comments

Comments
 (0)