Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tildes in the --project argument #28638

Closed
mortenpi opened this issue Aug 13, 2018 · 6 comments
Closed

Tildes in the --project argument #28638

mortenpi opened this issue Aug 13, 2018 · 6 comments
Labels
good first issue Indicates a good issue for first-time contributors to Julia help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@mortenpi
Copy link
Contributor

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?

@StefanKarpinski
Copy link
Member

Yes, seems like a good idea.

@StefanKarpinski StefanKarpinski added good first issue Indicates a good issue for first-time contributors to Julia help wanted Indicates that a maintainer wants help on an issue or pull request labels Apr 22, 2019
@Moelf
Copy link
Contributor

Moelf commented May 5, 2019

I'd like to fix this, is the argument handled in here?

jl_options.project = optarg ? strdup(optarg) : "@.";

@StefanKarpinski
Copy link
Member

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.

@Moelf
Copy link
Contributor

Moelf commented May 6, 2019

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"

@Moelf
Copy link
Contributor

Moelf commented May 6, 2019

With #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 

@fredrikekre
Copy link
Member

#31932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Indicates a good issue for first-time contributors to Julia help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

4 participants