# Pattern for activating the current project

**URL:** https://discourse.julialang.org/t/pattern-for-activating-the-current-project/15379
**Category:** General Usage
**Created:** [September 23, 2018, 12:55pm UTC](https://discourse.julialang.org/t/pattern-for-activating-the-current-project/15379 "2018-09-23T12:55:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)
#### Post date: [September 23, 2018, 12:55pm UTC](https://discourse.julialang.org/t/pattern-for-activating-the-current-project/15379/1 "2018-09-23T12:55:10Z")

</div>

Just wanted to make sure that I’m using the new `Pkg` API as intended:

1 - every time I develop a standalone app I create a folder. Then I start a REPL, go into `pkg>` mode and `activate .` Then I add the dependencies to the project.

2 - when I need to run the app through the `julia` binary, the environment defined in the folder is not automatically loaded. This leads to errors if the dependencies of the project aren’t added to the global environment as well (which they shouldn’t be, that’s why we have project dependencies).

3 - thus, my entry file into the app starts with:

```julia
using Pkg
pkg"activate ."

```

Is this the right way to do it or can it be done better?

Also, why not have Julia automatically look for a `Project.toml` file in the current dir and if it exists, use that automatically? It seems to me that if somebody went through the trouble of adding the `Project` file, one wants to use it. It seems more probable to me that developers will forget to activate the environment, versus accidentally activating an environment due to a `Project` file that should not be there (it doesn’t even make sense to me to think that a `Project` file is there but should not be used).

---

<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: [September 23, 2018, 1:02pm UTC](https://discourse.julialang.org/t/pattern-for-activating-the-current-project/15379/2 "2018-09-23T13:02:14Z")

</div>

> [@essenciary](#):
>
> Is this the right way to do it or can it be done better?

You can choose project at startup

```julia
julia --project=path/to/project

```

or

```julia
julia --project

```

which will look for `Project.toml` in current directory and its parents. You can also use the `JULIA_PROJECT` environment variable to specify this.

> [@essenciary](#):
>
> Also, why not have Julia automatically look for a `Project.toml` file in the current dir and if it exists, use that automatically?

See [Should the CurrentEnv path be set at julia startup and not follow with the pwd? · Issue #27411 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/27411), [Automatically load environments? · Issue #360 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/issues/360)

---

<div class="post-metadata">

### Author: ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)
#### Post date: [September 23, 2018, 1:09pm UTC](https://discourse.julialang.org/t/pattern-for-activating-the-current-project/15379/3 "2018-09-23T13:09:11Z")

</div>

Thanks, that’s good to know.

Am I abusing the API if I use this in the main file (I would say “no”):

```julia
using Pkg
pkg"activate ."

```

`direnv` sounds like a good way to handle it, thanks.
