# Custom location for ad-hoc package (code)

**URL:** <https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574>\
**Category:** New to Julia\
**Created:** [January 18, 2017, 9:51pm UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574 "2017-01-18T21:51:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [January 18, 2017, 9:51pm UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/1 "2017-01-18T21:51:33Z")

</div>

Is it possible to place a temporary ad-hoc package at an individually choosen location, say `~/code/julia/MyPkg.jl` ? The idea is, to gather some initial code in a ‘package-like’ form but - as it is quite temporary/unfinished - to separate it from the real packages.

From the manual (and tests) I suppose that ‘MyPkg.jl’ can only be placed under `~/.julia/v0.5` (or a custom `JULIA_PKGDIR` location which then is true for all packages).

Is this correct? (Side question: will this be possible with Pkg3?)  
Thank you!

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [January 18, 2017, 9:56pm UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/2 "2017-01-18T21:56:32Z")

</div>

You can use `LOAD_PATH`

For example,  
`push!(LOAD_PATH, "~/code/Julia")`

and this can be put into your `.juliarc.jl` so it loads when Julia starts.

---

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [January 18, 2017, 10:32pm UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/3 "2017-01-18T22:32:10Z")

</div>

`LOAD_PATH` works well with e.g. `using MyPkg`. However my - not mentioned - aim was to generate documentation:

```julia
using Documenter
Documenter.generate("MyPkg")

```

and here I still get an error (Unable to find package…). - Now looking at Documenter.jl:646 I see that `Pkg.dir` is being used and thus iiuc I’m back to `~/.julia/v0.5` as the only possibility.

---

<div class="post-metadata">

**Author:** ![mike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike/32/39_2.png) [@mike](https://discourse.julialang.org/u/mike)\
**Post date:** [January 19, 2017, 6:34am UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/4 "2017-01-19T06:34:50Z")

</div>

> [@swissr](#):
>
> However my - not mentioned - aim was to generate documentation

Modifying `LOAD_PATH` won’t help with that. See the docs for `generate` for how to do it:

```plaintext
help?> Documenter.generate
  generate(pkgname; dir)
  
  Creates a documentation stub for a package called pkgname. The location of the
  documentation is assumed to be <package directory>/docs, but this can be
  overriden with the keyword argument dir.

```

So you’ll need to specify the `dir` you’d like to use:

```plaintext
julia> Documenter.generate("MyPackage", dir = "<directory name>/docs")

```

Note that the `/docs` directory is created by `generate`; you’ll get an error if it already exists.

---

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [January 19, 2017, 10:03am UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/5 "2017-01-19T10:03:35Z")

</div>

Now it’s working fine 🙂

I tried with a dir argument before but missed that it is a keyword argument and 'dir = ’ is required. ‘LOAD\_PATH’ is also helpful for ‘using MyPkg’.

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 19, 2017, 10:44am UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/6 "2017-01-19T10:44:11Z")

</div>

Could you clarify why want to use another directory? Afaics i’m doing package development inside .julia/v0.5 (even without have a remote on github or similar) and apart from some complaints from Pkg.update had no real problems to solve. A package is just a git repository in place.

---

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [January 19, 2017, 11:57am UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/7 "2017-01-19T11:57:47Z")

</div>

For me ‘.julia’ screams _hidden_. And it’s where the standard julia package universe resides: Gallium, StaticArrays, RCall, Cxx, Documenter, PyPlot, … If technically necessary I would put my (ad-hoc) packages in there too, but if I have the choice I think they don’t belong there. (And where to put, under v0.4, v0.5 or v0.6)?

[Don’t know about Pkg.update complaints, for me this command is sometimes quite lengthy (homebrew) and I kind of avoid updating if not necessary].

The idea is to organize my own, ad-hoc or developing code, in projects having packages, e.g. `~/code/prj1/MyPkg1.jl`, `~/code/pr1/MyPkg2.jl` and `~/code/prj2` … The ‘packages’ are just a folder to organize relating code. While not (yet) proper packages, I still sometimes like to use the standard naming, testing and documenting conventions. Sometimes `MyPkg1.jl` is a git repository, but sometimes, for simplicity, the enclosing folder, `prj1` is the repository.

This said, atm I just wait until Pkg3 comes and will then adapt to ‘the rules’.

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 19, 2017, 12:47pm UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/8 "2017-01-19T12:47:23Z")

</div>

> [@swissr](#):
>
> For me ‘.julia’ screams hidden.

not only for you. Many of my text editors don’t show hidden files/dirs in file selector dialogs, so i needed to add execeptions. I still find .julia a poor choice for putting packages and code. For config or package information it might be matching. But i guess someone very early in the project found it a good idea and it was never discussed in a larger group. But again, it’s just ‘a’ directory that hold _all_ packages.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 19, 2017, 1:46pm UTC](https://discourse.julialang.org/t/custom-location-for-ad-hoc-package-code/1574/9 "2017-01-19T13:46:01Z")

</div>

Another simple way is to just symlink your package to `.julia` from whatever path you want to keep it at. It will from julias point of view look like a normally installed package.
