diff --git a/base/loading.jl b/base/loading.jl index c1ddabda6c469..0f64415c5f042 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -423,6 +423,7 @@ function env_project_file(env::String)::Union{Bool,String} project_file === nothing || return project_file end if isdir(env) + project_file = true for proj in project_names maybe_project_file = joinpath(env, proj) if isfile_casesensitive(maybe_project_file) @@ -430,7 +431,6 @@ function env_project_file(env::String)::Union{Bool,String} break end end - project_file =true elseif basename(env) in project_names && isfile_casesensitive(env) project_file = env else diff --git a/test/loading.jl b/test/loading.jl index 7dd6ce2935be6..ed75a3d114b66 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -156,6 +156,17 @@ end [deps] This = "$this_uuid" """) + + @test Base.env_project_file(joinpath(dir)) == project_file + @test Base.env_project_file(joinpath(project_file)) == project_file + + @test Base.env_project_file(joinpath(dir, "This")) === false + @test Base.env_project_file(joinpath(project_file, "This")) === false + + mkdir(joinpath(dir, "Inner")) + @test Base.env_project_file(joinpath(dir, "Inner")) === true + @test Base.env_project_file(joinpath(dir, "Inner", "Project.toml")) === false + # look up various packages by name root = Base.identify_package("Root") this = Base.identify_package("This")