如何查看所需的库文件名?例如 path / to / file.rb 或 path / to / file.so
$ rails c
Loading development environment (Rails 4.2.7.1)
[1] pry(main)> require "readline"
=> false
我想确保实际需要的确切文件路径,但不知道如何确认文件路径。
答案 0 :(得分:3)
Ruby有一个预定义的变量$"
或$LOADED_FEATURES
,其中包含所需的模块
$LOADED_FEATURES
#=> ["enumerator.so", "thread.rb", "rational.so", ...]
您可以使用grep
查找" readline":
$LOADED_FEATURES.grep /readline/
#=> ["/Users/sos/.rbenv/versions/2.4.0/lib/ruby/2.4.0/x86_64-darwin15/readline.bundle"]