Pkg.add() fails because registry folder is read-only

Hello, I am new to Julia, and I recently downloaded JuliaPro 1.0.5 on a new computer. However, I ran into trouble with Pkg.add() just into the third line, and none of the threads on julialang.org, stackexchange or GitHub solved my problem.

The error messages are:

julia> Pkg.add("GraphPlot")
   Cloning default registries into `~/.juliapro/JuliaPro_v1.0.5-2`
   Cloning registry from "https://pkg.juliacomputing.com/registry/General"
     Added registry `General` to `~/.juliapro/JuliaPro_v1.0.5-2/registries/General`
 Resolving package versions...
  Updating `/Project.toml`
  [a2cc645c] + GraphPlot v0.4.2
ERROR: SystemError: opening file /Project.toml: Read-only file system
Stacktrace:
 [1] #systemerror#39(::Nothing, ::Function, ::String, ::Bool) at /Applications/JuliaPro-1.0.5-2.app/Contents/Resources/julia/Contents/Resources/julia/lib/julia/sys.dylib:?
 [2] #open#295(::Nothing, ::Nothing, ::Nothing, ::Bool, ::Nothing, ::Function, ::String) at /Applications/JuliaPro-1.0.5-2.app/Contents/Resources/julia/Contents/Resources/julia/lib/julia/sys.dylib:?
 [3] #open#296(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:truncate,),Tuple{Bool}}}, ::Function, ::getfield(Pkg.Types, Symbol("##111#112")){Dict{String,Any}}, ::String) at /Applications/JuliaPro-1.0.5-2.app/Contents/Resources/julia/Contents/Resources/julia/lib/julia/sys.dylib:?
 [4] #open at ./none:0 [inlined]
 [5] write_project at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/Types.jl:1527 [inlined]
 [6] #write_project#115(::Bool, ::Function, ::Pkg.Types.Project, ::Pkg.Types.EnvCache, ::Pkg.Types.EnvCache, ::Pkg.Types.Context) at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/Types.jl:1541
 [7] #write_env#119 at ./none:0 [inlined]
 [8] write_env at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/Types.jl:1566 [inlined]
 [9] #add_or_develop#63(::Array{Base.UUID,1}, ::Symbol, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1237
 [10] #add_or_develop at ./none:0 [inlined]
 [11] #add_or_develop#17(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/API.jl:59
 [12] #add_or_develop at ./none:0 [inlined]
 [13] #add_or_develop#16 at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/API.jl:36 [inlined]
 [14] #add_or_develop at ./none:0 [inlined]
 [15] #add_or_develop#13 at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/API.jl:34 [inlined]
 [16] #add_or_develop at ./none:0 [inlined]
 [17] #add_or_develop#12 at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/API.jl:33 [inlined]
 [18] #add_or_develop at ./none:0 [inlined]
 [19] #add#22 at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/API.jl:64 [inlined]
 [20] add(::String) at /Users/vagrant/worker/juliapro-release-osx1011-0_6/build/tmp_julia/Julia-1.0.app/Contents/Resources/julia/share/julia/stdlib/v1.0/Pkg/src/API.jl:64
 [21] top-level scope at none:0

I have tried removing the ~/.juliapro/JuliaPro_v1.0.5-2/registries/General folder, changing its permission with chmod -R 755, but the error stays the same. I would appreciate it if you could point me to a relevant thread.

I believe the issue is:

  Updating `/Project.toml`

Which appears to be an absolute path. Like it’s trying to update a Project.toml at the root of the file system, which would be read-only. If you execute:

Pkg.status()

You should see something like:

julia> Pkg.status()
Status `~/julia/Project.toml`
  [6e4b80f9] BenchmarkTools v0.5.0
  [159f3aea] Cairo v1.0.3

Your projects will be different but the “Status” line will give you where Pkg is trying to create/update the Project.toml which should be in a directory you have write access to. I think Pkg.activate() can be used to set the correct location of Project.toml.

2 Likes

Thank you so much! I think it came down to me using Pkg.activate("../../") instead of using an absolute path, with the relative path pointing to some unintended location!