Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add Base.active_manifest #57924

Open
oscardssmith opened this issue Mar 28, 2025 · 1 comment · May be fixed by #57937
Open

Feature Request: Add Base.active_manifest #57924

oscardssmith opened this issue Mar 28, 2025 · 1 comment · May be fixed by #57937
Labels
feature Indicates new feature / enhancement requests packages Package management and loading

Comments

@oscardssmith
Copy link
Member

oscardssmith commented Mar 28, 2025

This is analogous to Base.active_project and returns the path of the active manifest file. This function likely doesn't exist yet because people assume it can be spelled joinpath(Base.active_project(), "Manifest.toml") which will work ~90% of the time, but the manifest can be called JuliaManifest.toml or [email protected] or if the Project.toml is using the [workspace] section, can live in a completely separate directory and be named anything.

Pkg has this information at Pkg.Types.EnvCache().manifest_file but that is pretty deep internals to Pkg and thus probably shouldn't be relied on.

@KristofferC
Copy link
Member

julia/base/loading.jl

Lines 821 to 857 in a046da5

# find project file's corresponding manifest file
function project_file_manifest_path(project_file::String)::Union{Nothing,String}
@lock require_lock begin
cache = LOADING_CACHE[]
if cache !== nothing
manifest_path = get(cache.project_file_manifest_path, project_file, missing)
manifest_path === missing || return manifest_path
end
dir = abspath(dirname(project_file))
d = parsed_toml(project_file)
base_manifest = workspace_manifest(project_file)
if base_manifest !== nothing
return base_manifest
end
explicit_manifest = get(d, "manifest", nothing)::Union{String, Nothing}
manifest_path = nothing
if explicit_manifest !== nothing
manifest_file = normpath(joinpath(dir, explicit_manifest))
if isfile_casesensitive(manifest_file)
manifest_path = manifest_file
end
end
if manifest_path === nothing
for mfst in manifest_names
manifest_file = joinpath(dir, mfst)
if isfile_casesensitive(manifest_file)
manifest_path = manifest_file
break
end
end
end
if cache !== nothing
cache.project_file_manifest_path[project_file] = manifest_path
end
return manifest_path
end
end

@nsajko nsajko added packages Package management and loading feature Indicates new feature / enhancement requests labels Mar 28, 2025
@IanButterworth IanButterworth linked a pull request Mar 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests packages Package management and loading
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants