Repository: JuliaLang/julia
File: base/initdefs.jl (Julia)

Code before:
!!! compat "Julia 1.8"
    This function requires at least Julia 1.8.
"""
function set_active_project(projfile::Union{AbstractString,Nothing})
    ACTIVE_PROJECT[] = projfile
    for f in active_project_callbacks
        try
            Base.invokelatest(f)
        catch
            @error "active project callback $f failed" maxlog=1
        end
    end
end

"""
    active_manifest()
    active_manifest(project_file::AbstractString)

Return the path of the active manifest file, or the manifest file that would be used for a given `project_file`.
See [`Project environments`](@ref project-environments) for details on the difference between a project and a manifest, and the naming
options and their priority in package loading.

See also [`Base.active_project`](@ref), [`Base.set_active_project`](@ref).
"""
function active_manifest(project_file::Union{AbstractString,Nothing}=nothing, search_load_path::Bool=true)
    project_file === @something project_file active_project(search_load_path)
    project_file === nothing && return nothing
    return project_file_manifest_path(project_file)
end

"""
    load_path()

Return the fully expanded value of [`LOAD_PATH`](@ref) that is searched for projects and
packages.

!!! note
    `load_path` may return a reference to a cached value so it is not safe to modify the
    returned vector.
"""
function load_path()
    cache = LOADING_CACHE[]
    cache !== nothing && return cache.load_path
    paths = String[]
    for env in LOAD_PATH
        path = load_path_expand(env)
        path !== nothing && path ∉ paths && push!(paths, path)
    end
    return paths
end


Review comment (suggestion):
```suggestion
    # If `project_file` was specified, use that, otherwise get the active project:
    project_file === !isnothing(project_file) ? project_file : active_project(search_load_path)
```

Code after:
!!! compat "Julia 1.8"
    This function requires at least Julia 1.8.
"""
function set_active_project(projfile::Union{AbstractString,Nothing})
    ACTIVE_PROJECT[] = projfile
    for f in active_project_callbacks
        try
            Base.invokelatest(f)
        catch
            @error "active project callback $f failed" maxlog=1
        end
    end
end

"""
    active_manifest()
    active_manifest(project_file::AbstractString)

Return the path of the active manifest file, or the manifest file that would be used for a given `project_file`.

In a stacked environment (where multiple environments exist in the load path), this returns the manifest
file for the primary (active) environment only, not the manifests from other environments in the stack.
See the manual section on [Environment stacks](@ref) for more details on how stacked environments work.

See [`Project environments`](@ref project-environments) for details on the difference between a project and a manifest, and the naming
options and their priority in package loading.

See also [`Base.active_project`](@ref), [`Base.set_active_project`](@ref).
"""
function active_manifest(project_file::Union{AbstractString,Nothing}=nothing; search_load_path::Bool=true)
    # If `project_file` was specified, use that, otherwise get the active project:
    project_file = !isnothing(project_file) ? project_file : active_project(search_load_path)
    project_file === nothing && return nothing
    return project_file_manifest_path(project_file)
end

"""
    load_path()

Return the fully expanded value of [`LOAD_PATH`](@ref) that is searched for projects and
packages.

!!! note
    `load_path` may return a reference to a cached value so it is not safe to modify the
    returned vector.
"""
function load_path()
    cache = LOADING_CACHE[]
    cache !== nothing && return cache.load_path
    paths = String[]
    for env in LOAD_PATH