JuliaLang / Pkg.jl

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

Request: Introduce Option to Freeze/Lock Environments #4041

Open alex-fu27 opened 3 weeks ago

alex-fu27 commented 3 weeks ago

Whenever I create a new project, I will forget to activate the new project's directory as an environment for installing packages. So I always install the packages into the default @#.# and later realize that no Project.toml was created. Then I uninstall the packages from the default environment and create the new Project.toml.

Thus, I would like to request a feature which can lock an environment, for example the default one, so that I get an error message if I try to install packages.

The hack I am currently using already implies a possible implementation: I did chmod a-w ~/.julia/environments/v1.10, which leads to an error when I try to add a package:

(@v1.10) pkg> add Plots
   Resolving package versions...
ERROR: SystemError: opening file "/home/alex/.julia/environments/v1.10/Project.toml": Permission denied
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:176
  [2] systemerror
    @ ./error.jl:175 [inlined]
  [3] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Bool, append::Nothing)
    @ Base ./iostream.jl:293
.... huge stack trace truncated...

Broken down into individual tasks, the implementation would be: