# How to add a folder path in your .jl script

**URL:** <https://discourse.julialang.org/t/how-to-add-a-folder-path-in-your-jl-script/61901>\
**Category:** New to Julia\
**Tags:** code-organization\
**Created:** [May 27, 2021, 5:26am UTC](https://discourse.julialang.org/t/how-to-add-a-folder-path-in-your-jl-script/61901 "2021-05-27T05:26:46Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [May 28, 2021, 1:51am UTC](https://discourse.julialang.org/t/how-to-add-a-folder-path-in-your-jl-script/61901/8 "2021-05-28T01:51:57Z")

</div>

### Almost there

I myself `push!()` my custom package library onto `LOAD_PATH` in much the same way as you do in your example @sxd190026.

And, despite some of the comments that almost seem to imply otherwise, I don’t believe this is necessarily a bad technique.

In fact, I find it is one of the easiest ways to add your custom library of utilities to new Julia projects. I think the only real drawback is that it doesn’t lend itself quite as well to sharing these Julia environments with other co-workers.

### `LOAD_PATH`

As @skleinbo said:

- `push!(LOAD_PATH, "/abs/path/to/my/package_lib")` essentially adds a _ **package library** _ folder to Julia’s search path.
- That means `include()` (_file_ loading mechanism) is unaffected by `LOAD_PATH`.
- However: `using` & `import` (_package_ loading mechanisms) _ **are** _ affected by `LOAD_PATH`.

### `include()` vs (`using` or `import`)

`include("relative/path/to/file.jl")`:

- Loads code from `file.jl`.

`import MyAwesomePackage`:

- Loads entire “package” `MyAwesomePackage`.

`using MyAwesomePackage`:

- Essentially does the same as `import MyAwesomePackage`
- But also makes any symbols `export`-ed from `MyAwesomePackage` directly available in the caller’s scope.

Also note that both `using` and `import` can be used with already-loaded modules (instead of packages) - but we’ll ignore that complexity for now (I don’t find it to be as useful in typical cases - or this discussion).

### So what was missing?

There were really only 2 things missing from your solution:

1. You should import your code _ **as a package** _ instead of loading it _ **as a file** _.
  - `using MyAwesomePackage` – instead of – `include("file_name.jl)`

2. Packages need to be wrapped in a `module` - `end` block.

So, in `"/abs/path/to/my/package_lib"`, I suggest you create a test package:

```julia
#MySingleFilePackage.jl
module MySingleFilePackage #Module needs to match file/package name

dosomething() = println("Execute all algorithms!")

export dosomething #If you don't want people to prepend call with "MySingleFilePackage."

end #module MySingleFilePackage

```

And try it out in your script:

```julia
#Just try not to run push!() more than once in your scripts:
push!(LOAD_PATH, "/abs/path/to/my/package_lib")

using MySingleFilePackage
dosomething()

```

### What if I want to create a multi-file package?

Then I suggest you follow the structure for full-blown package described by @GunnarFarneback.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-add-a-folder-path-in-your-jl-script/61901)._
