# Error in command line arg --project with "~"

**URL:** <https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307>\
**Category:** General Usage\
**Created:** [April 19, 2019, 2:45pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307 "2019-04-19T14:45:54Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![v-i-s-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/v-i-s-h/32/46152_2.png) [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Post date:** [April 19, 2019, 2:45pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/1 "2019-04-19T14:45:54Z")

</div>

I was testing a package and want to set the package as my project directory for test.  
When I pass my relative path `~/.julia/dev/Gym/` as `--project=`, the following error occurs.

```julia
vish@eliteone:~/.julia/dev/Gym$ julia --project=~/.julia/dev/Gym/ -e "using Pkg; Pkg.test(\"Gym\")" --color=yes
ERROR: The following package names could not be resolved:
 * Gym (not found in project or manifest)
Please specify by known `name=uuid`.
Stacktrace:
 [1] pkgerror(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:120
 [2] #ensure_resolved#72(::Bool, ::Function, ::Pkg.Types.EnvCache, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:1010
 [3] ensure_resolved at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:981 [inlined]
 [4] #test#44(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:189
 [5] test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:178 [inlined]
 [6] #test#43 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:175 [inlined]
 [7] test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:175 [inlined]
 [8] #test#42 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:174 [inlined]
 [9] test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:174 [inlined]
 [10] #test#41(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:173
 [11] test(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:173
 [12] top-level scope at none:0

```

However if I specify the full path, it works.

```julia
vish@eliteone:~/.julia/dev/Gym$ julia --project=/home/vish/.julia/dev/Gym/ -e "using Pkg; Pkg.test(\"Gym\")" --color=yes
   Testing Gym
 Resolving package versions...
Test Summary: | Pass Broken Total
Spaces | 82 12 94
   Testing Gym tests passed 

```

How can I expand “~” for setting project automatically?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [April 19, 2019, 5:52pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/2 "2019-04-19T17:52:40Z")

</div>

Only your shell knows what `~` means; to Julia it’s just another character. However, you can tell your shell to expand it to your actual home directory using the `$HOME` environment variable. For example:

```julia
julia --project="$HOME/.julia/dev/Gym" ...

```

---

<div class="post-metadata">

**Author:** ![v-i-s-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/v-i-s-h/32/46152_2.png) [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Post date:** [April 20, 2019, 3:10am UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/3 "2019-04-20T03:10:39Z")

</div>

Thanks 🙂 It works!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 20, 2019, 2:04pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/4 "2019-04-20T14:04:52Z")

</div>

> [@v-i-s-h](#):
>
> vish@eliteone:~/.julia/dev/Gym$ julia --project=~/.julia/dev/Gym/

Note that you don’t need an absolute path to `--project`, so from the example above where you already are in the same folder as your project you can just use

```julia
julia --project=.

```

or use

```julia
julia --project

```

which makes julia look for a project file in `$PWD` and upwards.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [April 21, 2019, 1:40pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/5 "2019-04-21T13:40:28Z")

</div>

Julia could also _address_ this issue internally,

> [@How to use ~ in a Cmd](https://discourse.julialang.org/t/how-to-use-in-a-cmd/22844/2):
>
> Call expanduser on the path first.

by calling `expanduser` on the string.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [April 21, 2019, 1:41pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/6 "2019-04-21T13:41:28Z")

</div>

Sure, but calling that a “fix” is already making a judgment call about which behavior is correct. I’m not saying we shouldn’t do it but it’s not obviously the right thing to do.

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [April 21, 2019, 2:00pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/7 "2019-04-21T14:00:58Z")

</div>

If we agree that ~ is a fairly universal way of indicating user’s home directory and the variable correspond to a directory, then i would think it’s reasonable to expand the character. The drawback is that it would never recognize ~ itself as part of a directory path without escaping it.

---

<div class="post-metadata">

**Author:** ![v-i-s-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/v-i-s-h/32/46152_2.png) [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Post date:** [April 22, 2019, 3:26am UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/8 "2019-04-22T03:26:34Z")

</div>

> [@tk3369](#):
>
> The drawback is that it would never recognize ~ itself as part of a directory path without escaping it.

I did not understand this part. Why escape it?

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [April 22, 2019, 4:08am UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/9 "2019-04-22T04:08:05Z")

</div>

It would be an edge case that some crazy person could still use the ~ character as part of a directory name. If we always expand on it then this directory can never be referenced. Honestly I don’t think that’s a big deal.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [April 22, 2019, 4:13am UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/10 "2019-04-22T04:13:35Z")

</div>

You could avoid that edge case by only matching the `~` character at the beginning of the path?

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [April 22, 2019, 4:16am UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/11 "2019-04-22T04:16:16Z")

</div>

That’s a great point!

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [April 22, 2019, 11:52am UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/12 "2019-04-22T11:52:11Z")

</div>

Seems like a good idea. Would one of you mind opening an issue about changing the project option to expand the user name?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 22, 2019, 1:50pm UTC](https://discourse.julialang.org/t/error-in-command-line-arg-project-with/23307/14 "2019-04-22T13:50:36Z")

</div>

[https://github.com/JuliaLang/julia/issues/28638](https://github.com/JuliaLang/julia/issues/28638)
