# @\_\_DIR\_\_ versus Pkg.dir

**URL:** https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580
**Category:** New to Julia
**Tags:** question
**Created:** [August 26, 2017, 8:22pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580 "2017-08-26T20:22:16Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [August 26, 2017, 8:22pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/1 "2017-08-26T20:22:16Z")

</div>

Are there any differences between using `@ __DIR__ ` from within the package’s home directory and `Pkg.dir`? I understand that `@ __DIR__ ` gives the path to the folder where the current file is in, and `Pkg.dir` gives the path to the home directory of the given package, but are there any differences in speed, breakability, robustness, or things one should keep in mind when using one and not the other?

Thanks!

---

<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: [August 26, 2017, 9:30pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/2 "2017-08-26T21:30:00Z")

</div>

Packages are not necessarily installed in the `Pkg.dir` folder. Just use `@ __DIR__ ` if you can.

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [August 27, 2017, 5:26am UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/3 "2017-08-27T05:26:44Z")

</div>

I see. Cool, thanks.

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [September 7, 2017, 2:40pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/4 "2017-09-07T14:40:22Z")

</div>

I’ve followed your advice, and it occurred to me, it’s kind of crazy that packages can be installed in different places. It would be nice if we, as developers, could trust at least that much, that the package is in `Pkg.dir`…  
Or to put it in another way: the hassle of dealing with putting a package anywhere else other than in the standard place should fall on the user, if said user decided to deviate from standard, not on the developer. So if there are any hoops to jump through when putting a package somewhere weird and _still_ have a functioning system, then that’s up to the user. The developer should be able to assume that packages are where they should be…  
Sorry for the rant.

---

<div class="post-metadata">

### Author: ![Michael\_Eastwood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael_eastwood/32/669_2.png) [@Michael\_Eastwood](https://discourse.julialang.org/u/Michael_Eastwood)
#### Post date: [September 7, 2017, 3:44pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/5 "2017-09-07T15:44:14Z")

</div>

I disagree. What if I want to install a package system-wide instead of per-user? In that case the package goes in `/usr/local/share/julia/site/v0.6` instead of the usual `Pkg.dir`. This isn’t a weird thing to do, so I would hope it works without jumping through too many hoops as a user. I don’t think it’s that much of a burden to write a package that is agnostic about where it is installed. Is there a particular problem you are having trouble with?

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [September 7, 2017, 3:57pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/6 "2017-09-07T15:57:06Z")

</div>

I would also add (from a discussion with Jameson a while ago) that there’s a difference between the code/data (read only) location and user data location. The first should be allowed to be anywhere (that julia can find, i.e. LOAD\_PATH) while Pkg.dir would fill in the rule for the latter quite well.

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [September 7, 2017, 6:07pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/7 "2017-09-07T18:07:43Z")

</div>

OK, I see. I didn’t realize there are two distinct entities for each package: 1) the system read only data and 2) local per-user data.

Mu specific case is that I have a bunch of nested folders in my package and I need to reference stuff. So to get the current directory, move one up, and then into some other folder, I end up doing this: `joinpath(first(splitdir(@ __DIR__ )), "some_folder")`. Seems like it would be nice to have a function for that.  
Then again, I could just set `const src = first(splitdir(@ __DIR__ ))` in the main module file and work with that.

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [September 7, 2017, 6:15pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/8 "2017-09-07T18:15:54Z")

</div>

`joinpath(@ __DIR__ , "..", "some_folder")`

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [September 7, 2017, 6:53pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/9 "2017-09-07T18:53:15Z")

</div>

And this works on Windows as well…?

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [September 7, 2017, 7:05pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/10 "2017-09-07T19:05:48Z")

</div>

It should. Also even `joinpath(@ __DIR__ , "../some_folder")` should work on Windows.

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [September 7, 2017, 7:15pm UTC](https://discourse.julialang.org/t/--dir---versus-pkg-dir/5580/11 "2017-09-07T19:15:16Z")

</div>

Awesome, thanks a lot!
