File.expand_path(“../../Gemfile”, __FILE__) How does this work? Where is the file?

前端 未结 2 1908
深忆病人
深忆病人 2020-12-07 08:23

ENV[\"BUNDLE_GEMFILE\"] = File.expand_path(\"../../Gemfile\", __FILE__)

I\'m just trying to access a .rb file from the some directory and a tutorial is

2条回答
  •  渐次进展
    2020-12-07 08:51

    Two references:

    1. File::expand_path method documentation
    2. How does __FILE__ work in Ruby

    I stumbled across this today:

    boot.rb commit in the Rails Github

    If you go up two directories from boot.rb in the directory tree:

    /railties/lib/rails/generators/rails/app/templates

    you see Gemfile, which leads me to believe that File.expand_path("../../Gemfile", __FILE__) references following file: /path/to/this/file/../../Gemfile

提交回复
热议问题