How does rake know where to look for rake files?

I am trying to better understand how rake works. I looked at the rake website to find out how it works, but there is no clear explanation of how rake searches for Rakefiles and the steps that it takes to resolve dependencies. Can anyone explain how rake works?

+4
source share
1 answer

By default, rake will look for one of these files in the directory from which you executed it:

  • rakefile
  • Rakefile
  • rakefile.rb
  • Rakefile.rb

You can watch Rake Applications to view this list.

In addition, any ruby ​​file, including other rakefiles, can be included with the standard Ruby require command:

 require 'rake/loaders/external-rakefile' 

you can import them:

 import 'rake/loaders/external-rakefile' 

To make the Rake task set available for use from any directory, create a .rake subdirectory in your home directory and place the appropriate Rake files there. Any rake command with the -g option will use these global Rake files (more info here ):

 rake -g -T 

In addition, if the -g option is set, Rake will first try to load the environment variable form file RAKE_SYSTEM , if it is not set, the default will be home user directory/.rake/*.rake . These files will be downloaded / imported in addition to one of the default files listed above.

Otherwise, it will load the first default file (from the list above) and additionally import all rake files from the rakelib directory (at the address where you run rake ), or you can specify this directory using:

 --rakelibdir=RAKELIBDIR or -R RAKELIBDIR: Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib') 
+15
source

All Articles