JuliaLang / Pkg.jl

Pkg - Package manager for the Julia programming language
https://pkgdocs.julialang.org
Other
621 stars 268 forks source link

Pkg.build errors when depot is read-only #1218

Open simonbyrne opened 5 years ago

simonbyrne commented 5 years ago

Part of making making system-provided depots useable (#763, #669). Pkg.build() will attempt to rebuild packages in all depots, and error if any of them are read-only.

Example from https://github.com/JuliaLang/Pkg.jl/pull/733#issuecomment-498941123:

using Pkg

envdir = mktempdir()

depot1 = mktempdir()
depot2 = mktempdir()

Pkg.activate(envdir)

resize!(DEPOT_PATH, 1)
DEPOT_PATH[1] = depot2
Pkg.add("Arpack") # add Arpack to depot2

resize!(DEPOT_PATH, 2)
DEPOT_PATH[1] = depot1
DEPOT_PATH[2] = depot2
Pkg.add("Rmath") # add Rmath to depot1

Pkg.build() # this works

run(`chmod -R ugo-w $depot2`) # make depot2 read-only

Pkg.build() # this fails

julia> Pkg.build() # this fails
  Building Arpack → `/var/folders/50/q7_qvjks4c5dj_51zd0cp4cw0000gn/T/tmpkcDoqm/packages/Arpack/cu5By/deps/build.log`
ERROR: SystemError: opening file "/var/folders/50/q7_qvjks4c5dj_51zd0cp4cw0000gn/T/tmpkcDoqm/packages/Arpack/cu5By/deps/build.log": Permission denied
Stacktrace:
 [1] #systemerror#43(::Nothing, ::Function, ::String, ::Bool) at ./error.jl:134
 [2] systemerror at ./error.jl:134 [inlined]
 [3] #open#309(::Nothing, ::Nothing, ::Nothing, ::Bool, ::Nothing, ::Function, ::String) at ./iostream.jl:283
 [4] #open at ./none:0 [inlined]
 [5] open(::String, ::String) at ./iostream.jl:339
 [6] #open#310(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(Pkg.Operations, Symbol("##52#57")){Bool,Cmd}, ::String, ::Vararg{String,N} where N) at ./iostream.jl:367
 [7] open at ./iostream.jl:367 [inlined]
 [8] (::getfield(Pkg.Operations, Symbol("##51#56")){Bool,String,Cmd,String})() at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1060
 [9] #53 at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1080 [inlined]
 [10] #41 at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:898 [inlined]
 [11] withenv(::getfield(Pkg.Operations, Symbol("##41#46")){getfield(Pkg.Operations, Symbol("##53#58")){getfield(Pkg.Operations, Symbol("##51#56")){Bool,String,Cmd,String}},Pkg.Types.Context}, ::Pair{String,String}, ::Vararg{Pair{String,B} where B,N} where N) at ./env.jl:148
 [12] (::getfield(Pkg.Operations, Symbol("##40#44")){Bool,getfield(Pkg.Operations, Symbol("##53#58")){getfield(Pkg.Operations, Symbol("##51#56")){Bool,String,Cmd,String}},Pkg.Types.Context,Pkg.Types.PackageSpec,Pkg.Types.Context})(::String) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:897
 [13] mktempdir(::getfield(Pkg.Operations, Symbol("##40#44")){Bool,getfield(Pkg.Operations, Symbol("##53#58")){getfield(Pkg.Operations, Symbol("##51#56")){Bool,String,Cmd,String}},Pkg.Types.Context,Pkg.Types.PackageSpec,Pkg.Types.Context}, ::String) at ./file.jl:581
 [14] mktempdir at ./file.jl:579 [inlined]
 [15] #with_dependencies_loadable_at_toplevel#38(::Bool, ::Function, ::getfield(Pkg.Operations, Symbol("##53#58")){getfield(Pkg.Operations, Symbol("##51#56")){Bool,String,Cmd,String}}, ::Pkg.Types.Context, ::Pkg.Types.PackageSpec) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:853
 [16] #with_dependencies_loadable_at_toplevel at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:0 [inlined]
 [17] #build_versions#48(::Bool, ::Bool, ::Function, ::Pkg.Types.Context, ::Array{Base.UUID,1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1078
 [18] #build_versions at ./none:0 [inlined]
 [19] #build#59(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:377
 [20] build at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:352 [inlined]
 [21] #build#58 at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:350 [inlined]
 [22] build at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:350 [inlined]
 [23] #build#55 at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:347 [inlined]
 [24] build() at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:347
 [25] top-level scope at none:0
KristofferC commented 5 years ago

Do you have a suggestion of what would be a better experience?

simonbyrne commented 5 years ago

I'm not sure. Maybe build should only operate on packages in the first depot by default? You could provide a -depot=n option to specify which depot to build, or -all to rebuild all?

KristofferC commented 5 years ago

Yeah, I see we only update registries in first deport entry so is perhaps sensible to do the same for build.