# Setting the working directory to the directory of current open file as default?

**URL:** <https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089>\
**Category:** Juno\
**Created:** [April 12, 2019, 6:10pm UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089 "2019-04-12T18:10:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmetumutdurmus](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@ahmetumutdurmus](https://discourse.julialang.org/u/ahmetumutdurmus)\
**Post date:** [April 12, 2019, 6:10pm UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/1 "2019-04-12T18:10:53Z")

</div>

Hello,

When I open a Julia file in Atom my working directory is automatically set to my HOME directory. Thus I have to either explicitly code: `cd(dirname(@ __FILE__ ))` or use the following command: `Julia Client: Work in File Folder`. Is there a way to avoid this altogether and make it default behavior? I believe this is similar to the issues [#490](https://github.com/JunoLab/atom-julia-client/issues/490) and [#124](https://github.com/JunoLab/atom-julia-client/issues/124) . Yet it seems to have been resolved in issue `#124`.  
When I create the file `Example.jl` with the following code:

```julia
println(pwd())
cd(dirname(@ __FILE__ ))
println(pwd()) 

```

inside and run it I get the following output in the REPL below:

> C:\Users\adurmus  
> C:\Users\adurmus\Desktop\Folder #1

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [April 13, 2019, 11:57am UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/2 "2019-04-13T11:57:15Z")

</div>

> [@ahmetumutdurmus](#):
>
> When I open a Julia file in Atom my working directory is automatically set to my HOME directory.

What is the project folder? In other words, when you look at tree view (usually the view of files and folders on the left part of the window) are you seeing all the folders in your home folder or just `Folder #1`?

---

<div class="post-metadata">

**Author:** ![ahmetumutdurmus](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@ahmetumutdurmus](https://discourse.julialang.org/u/ahmetumutdurmus)\
**Post date:** [April 14, 2019, 8:33am UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/3 "2019-04-14T08:33:00Z")

</div>

So when I open up a julia file in Atom by just double clicking it, no tree view pane shows up. When I select `Tree View:Toggle` command, a project pane pops up but I am not seeing any folders inside it. Here is a screenshot of what I am seeing:

 ![Screenshot%20(10)](https://global.discourse-cdn.com/julialang/original/3X/f/d/fd4a753fc3bb46a7a72361ad6cdca171d6421d95.png)

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [April 14, 2019, 12:48pm UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/4 "2019-04-14T12:48:03Z")

</div>

Try adding a project folder there, or else right-click the folder of the project you’re working on and open it in atom. I’m guessing that because there’s no project folder, Juno is just defaulting to `$HOME`.

---

<div class="post-metadata">

**Author:** ![Deduction42](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deduction42/32/9206_2.png) [@Deduction42](https://discourse.julialang.org/u/Deduction42)\
**Post date:** [June 8, 2019, 6:08pm UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/5 "2019-06-08T18:08:12Z")

</div>

It would be nice if there could be some sort of Juno setting that we could select to automatically cd Julia to the directory containing the first-opened file (instead of going Julia → Working Directory → Current File’s Folder). It used to work this way before Atom updated to v1.36. I could understand if not everyone wants this behavior, but I think most people would and this should definitely be an option.

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [October 13, 2019, 8:35am UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/6 "2019-10-13T08:35:36Z")

</div>

> [@kevbonham](#):
>
> Juno is just defaulting to `$HOME`.

Is there a way to launch it with a different default?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [October 13, 2019, 8:44am UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/7 "2019-10-13T08:44:41Z")

</div>

If you start with e.g. `atom .` then Juno should set `.` as the working dir automatically (given that you don’t have any other project folders open).

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [October 13, 2019, 8:48am UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/8 "2019-10-13T08:48:13Z")

</div>

Perfect, so at the Juno launcher in JuliaPro I set `start "%USERPROFILE%" "app-1.40.1/atom.exe" %JULIADOC%` where `JULIADOC` is where I want it to start.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [October 13, 2019, 8:52am UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/9 "2019-10-13T08:52:35Z")

</div>

Well, maybe – I haven’t actually tried this. `atom path/do/somewhere` will add `somewhere` as a project folder in Atom, and Juno will start Julia processes in the first project folder by default.

There actually is a better solution though: Fill in the two following entries in `julia-client`s settings and you should be good to go.

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/1/c/1c670746a35be8a76c6d8bf013f13403b100e012.png)

Although `Working Directory` will be updated if you change the working dir through Juno (e.g. with the `Work In File Folder` command; `cd` in Julia doesn’t have an effect though).

---

<div class="post-metadata">

**Author:** ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)\
**Post date:** [December 6, 2019, 9:24pm UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/10 "2019-12-06T21:24:08Z")

</div>

Has this been resolved? It seems that $HOME is always the default folder and not the starting folder. This is very counterintuitive…

---

<div class="post-metadata">

**Author:** ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)\
**Post date:** [December 7, 2019, 12:31am UTC](https://discourse.julialang.org/t/setting-the-working-directory-to-the-directory-of-current-open-file-as-default/23089/11 "2019-12-07T00:31:13Z")

</div>

Ah, found it: Juno-\>Working Directory-\>Current File’s Folder
