Skip to main content

rb_load

Function rb_load 

Source
pub unsafe extern "C" fn rb_load(path: VALUE, wrap: c_int)
Expand description

Loads and executes the Ruby program in the given file.

If the path is an absolute path (e.g. starts with '/'), the file will be loaded directly using the absolute path. If the path is an explicit relative path (e.g. starts with './' or '../'), the file will be loaded using the relative path from the current directory. Otherwise, the file will be searched for in the library directories listed in the $LOAD_PATH. If the file is found in a directory, this function will attempt to load the file relative to that directory. If the file is not found in any of the directories in the $LOAD_PATH, the file will be loaded using the relative path from the current directory.

If the file doesn’t exist when there is an attempt to load it, a LoadError will be raised.

If the wrap parameter is true, the loaded script will be executed under an anonymous module, protecting the calling program’s global namespace. In no circumstance will any local variables in the loaded file be propagated to the loading environment.

@param[in] path Pathname of a file to load. @param[in] wrap Either to load under an anonymous module. @exception rb_eTypeError path is not a string. @exception rb_eArgError path is broken as a pathname. @exception rb_eEncCompatError path is incompatible with pathnames. @exception rb_eLoadError path not found. @exception rb_eException Any exceptions while loading the contents.

@internal

§It seems this function is under the rule of bootsnap’s regime?

Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.3.8