The --project command line argument does not expand tildes. Perhaps it should?
/tmp$ julia --project=~/Foo -e'using Pkg; Pkg.status()'
Status `/tmp/~/Foo/Project.toml`
Would expect:
/tmp$ julia --project=~/Foo -e'using Pkg; Pkg.status()'
Status `/home/user/Foo/Project.toml`
cc @fredrikekre since #28625 might be related?
Yes, seems like a good idea.
I'd like to fix this, is the argument handled in here? https://github.com/JuliaLang/julia/blob/1be1deb10c90b612a57d3541d3bf1aae1a42e104/src/jloptions.c#L410
That's where the option is parsed but it's better to handle the user expansion later, e.g.:
diff --git a/base/initdefs.jl b/base/initdefs.jl
index 479f3bd447..0eef60b01c 100644
--- a/base/initdefs.jl
+++ b/base/initdefs.jl
@@ -214,6 +214,9 @@ function init_load_path()
project = (JLOptions().project != C_NULL ?
unsafe_string(Base.JLOptions().project) :
get(ENV, "JULIA_PROJECT", nothing))
+ if project != nothing
+ project = expanduser(project)
+ end
HOME_PROJECT[] =
project === nothing ? nothing :
project == "" ? nothing :
You'll need to verify that this works and test it.
Apparently Base.JLOptions().project is already expanded:
$/tmp julia --project=~/Documents -e'@show unsafe_string(Base.JLOptions().project)'
unsafe_string((Base.JLOptions()).project) = "/tmp/~/Documents"
With https://github.com/JuliaLang/julia/pull/31932 :
~/Doc…/git…/julia ./julia$ pwd
/home/akako/Documents/github/julia
~/Doc…/git…/julia$ ./julia --project= -e'using Pkg; Pkg.status()'
Status `~/.julia/environments/v1.3/Project.toml`
(empty environment)
~/Doc…/git…/julia$ ./julia --project=~ -e'using Pkg; Pkg.status()'
Status `~/Project.toml`
(no changes since last commit)
~/Doc…/git…/julia$ ./julia --project=~/Documents/github/Telegrambot.jl -e'using Pkg; Pkg.status()'
Project Telegrambot v0.1.3
Status `~/Documents/github/Telegrambot.jl/Project.toml`
[cd3eb016] HTTP v0.8.0
[682c06a0] JSON v0.20.0
[8dfed614] Test
[cf7118a7] UUIDs