# How to set environment for local Julia package in module

**URL:** https://discourse.julialang.org/t/how-to-set-environment-for-local-julia-package-in-module/100106
**Category:** New to Julia
**Created:** [June 9, 2023, 1:48pm UTC](https://discourse.julialang.org/t/how-to-set-environment-for-local-julia-package-in-module/100106 "2023-06-09T13:48:10Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![George9000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/george9000/32/23619_2.png) [@George9000](https://discourse.julialang.org/u/George9000)
#### Post date: [June 9, 2023, 2:15pm UTC](https://discourse.julialang.org/t/how-to-set-environment-for-local-julia-package-in-module/100106/6 "2023-06-09T14:15:40Z")

</div>

Gaussia, here’s a workflow that performs well for my needs.

After adding Revise to your default `v1.X` environment, in a ~/.julia/config/startup.jl file, have the following:

```julia
using Pkg
if isfile("Project.toml") && isfile("Manifest.toml")
    Pkg.activate(".")
end
try
    using Revise
catch e
    @warn "Error initializing Revise" exception=(e, catch_backtrace())
end

```

Now, make a package for a project.

```julia
cd ~/Documents
julia -e 'using Pkg; Pkg.generate("example")'

cd example
julia -e 'using Pkg; Pkg.activate(".");Pkg.instantiate()'

ls -l
Manifest.toml
Project.toml
src <-- your module lives in this subdirectory

touch playground.jl <-- your project script

ls -l
Manifest.toml
playground.jl
Project.toml
src

ls -l src
example.jl <-- your module

```

Once this is set up, when julia is launched in the example directory, it should use the `example` project as the environment. Any packages added in the session should then be available to the playground.jl script or the example.jl module via a `using X` line in those files.

Your default `v1.X` environment, launched outside the example directory, should have only a couple packages used everywhere, such as Revise or Infiltrator. Remove other packages added by mistake to that default environment.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-set-environment-for-local-julia-package-in-module/100106)._
