# Recommendations for how to browse source code

**URL:** <https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303>\
**Category:** Tooling\
**Created:** [May 17, 2019, 3:20am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303 "2019-05-17T03:20:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [May 17, 2019, 3:20am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/1 "2019-05-17T03:20:46Z")

</div>

I want to understand how the GLM package works by looking at the source code.  
I used the package manager’s develop command to get the code.

1. I asked for a local install, thinking it would go to my local directory. But instead it’s a few layers down from my Windows “home” directory (~/.julia/…). Is there a way to put it under my project directory? Even if there is, is that a bad idea?

2. The package makes extensive use of code from other packages. The package manager brought them in automatically, but apparently as binary packages. Which don’t help much if I want to see the source. I could chase through the references by hand and get a develop version of each, but is there are more automatic way to do so?

It may also matter that my intention differs some from that which the package manager develop is designed. The latter is about getting and modifying a package; I only want to browse the source.

1. I thought once I had the source code juno would help me with things like lists of types and functions, quick jumping to definitions, references or calls, but the documentation for juno doesn’t seem to mention such features. There is a “go to definition” shortcut which sounded promising, but in my limited attempts it didn’t do anything. Possibly this is caused by 1 or 2 (more likely 2–it obviously can’t show the source if there is no source available), or by the fact that I hadn’t loaded any of the modules since I just wanted to browse the source. What tools can be helpful in understanding and navigating source code from several modules?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [May 17, 2019, 4:48am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/2 "2019-05-17T04:48:10Z")

</div>

```julia
git clone https://github.com/JuliaStats/GLM.jl.git

```

and

```julia
]dev ../GLM.jl

```

will put the source at your fingertips.

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [May 17, 2019, 5:18am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/3 "2019-05-17T05:18:31Z")

</div>

> [@Ross\_Boylan](#):
>
> I asked for a local install, thinking it would go to my local directory. But instead it’s a few layers down from my Windows “home” directory (~/.julia/…). Is there a way to put it under my project directory? Even if there is, is that a bad idea?

Not sure what you mean by “asked for a local install”. If you `dev`ed the package, where it ends up is controlled by the `JULIA_PKG_DEVDIR` environment variable (see [3. Managing Packages · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/managing-packages/#Developing-packages-1)). If you `add`ed the package, where it ends up is controlled by the `DEPOT_PATH` Julia global variable and the `JULIA_DEPOT_PATH` environment variable (see [9. Glossary · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/glossary/)). Or you can manually clone and then `dev` the local path like @PetrKryslUCSD suggested.

> [@Ross\_Boylan](#):
>
> The package manager brought them in automatically, but apparently as binary packages.

There’s not really such a thing as a binary Julia package, at least not in this sense. The source code for package dependencies is always downloaded; it’s just a question of finding where it is. One way to do so is as follows:

```julia
julia> using SIMD # for example

julia> pathof(SIMD)
"/Users/tkoolen/.julia/packages/SIMD/nqizO/src/SIMD.jl"

```

Note that the the `nqizO` part of the directory is an implementation detail (used to distinguish between different versions of the same package) and that you shouldn’t edit the source code of packages in `.julia/packages`. But you can still view the code.

In addition, there are a bunch of tools for exploring source code (all available without an IDE):

- the `@edit` and `@less` macros (see `? @edit`)
- [InteractiveCodeSearch.jl](https://github.com/tkf/InteractiveCodeSearch.jl)
- [Debugger.jl](https://github.com/JuliaDebug/Debugger.jl) can be handy as well

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [May 17, 2019, 8:41am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/4 "2019-05-17T08:41:34Z")

</div>

I would use the Pkg facility for installing a local development copy.  
Enter into the Pkg prompt ]  
Create a new Project directory (it cannot be named GLM):  
generate myGLM  
activate myGLM  
develop --local GLM.jl

Then open a terminal window and enter the directory ~/myGM  
In the dev directory you will find a git clone of GLM.jl

If you want to make changes to the code and test them out locally this is the way to do it.

---

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [May 17, 2019, 5:14pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/5 "2019-05-17T17:14:55Z")

</div>

Thanks to you and the others for very helpful info.

By local install I meant I used the --local option. The docs say the option sends installs into the dev directory of the current project. I thought that meant the current working directory, but it didn’t create a dev subdirectory there. Do I somehow need to set up a project? What is a project?

Ross

---

<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:** [May 18, 2019, 10:27am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/6 "2019-05-18T10:27:38Z")

</div>

> [@Ross\_Boylan](#):
>
> The docs say the option sends installs into the dev directory of the current project. I thought that meant the current working directory, but it didn’t create a dev subdirectory there

No, it means the current Project™ - which is minimally a folder with a Project.toml file (I think). But you need to `]activate` it in order for you to be working in the project. When you start Julia, the project you’re working in is `1.x`. [See here](https://docs.julialang.org/en/v1/stdlib/Pkg/index.html)

> [@Ross\_Boylan](#):
>
> Do I somehow need to set up a project? What is a project?

> [@johnh](#):
>
> Enter into the Pkg prompt ]  
> Create a new Project directory (it cannot be named GLM):  
> generate myGLM  
> activate myGLM

You can also `] activate .` to start a project in the current working directory.

---

<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:** [May 18, 2019, 11:38am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/7 "2019-05-18T11:38:40Z")

</div>

[4. Working with Environments · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/environments/) might be useful.

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [May 18, 2019, 1:12pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/8 "2019-05-18T13:12:04Z")

</div>

@Ross_Boylan happy to talk you through setting up a project like this.  
It is really very easy - even I can do it!

---

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [May 20, 2019, 6:45pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/9 "2019-05-20T18:45:59Z")

</div>

Thanks to all, I think I understand.

Reading the fine manual seems to be a bit of a 2-pass experience.

[The basic description of pkg](https://docs.julialang.org/en/v1/stdlib/Pkg/index.html) starts with an explicit, though informal and partial, description of **environment** , and then drops in **project** with no explanation half-way down, in the context of mentioning “your project directory”. The same material appears as section 2 of the [full Pkg manual](https://julialang.github.io/Pkg.jl/v1/), but that manual doesn’t get around to projects until section 4. Section 3 also contains passing references to projects. Projects are defined (if that’s not too strong a word) in the glossary, section 8. Additional details appear in the discussion of code loading in the [main julia manual](https://docs.julialang.org/en/v1/manual/code-loading/#Project-environments-1).

This is all in the context of the intro to the Pkg manual which states

> Pkg is designed around “environments”: independent sets of packages that can be local to an individual project or shared and selected by name.

So while reading sections 2 and 3 I thought I was reading about manipulations of environments, not projects. But apparently pkg is also the project manager.

I think the docs could be clearer, though of course that’s easier to say than to do.

---

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [May 20, 2019, 7:04pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/10 "2019-05-20T19:04:32Z")

</div>

I can’t resist an old joke about 2-pass algorithms:

An old lady gets on a bus and sits down next to a kid. She turns to him and asks “I’ve never taken this route. Could you help me get off at Clark road?”

Kid: “Sure. Just watch where I get off, and leave at the stop before that.”

---

<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:** [May 20, 2019, 7:13pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/11 "2019-05-20T19:13:17Z")

</div>

> [@Ross\_Boylan](#):
>
> I think the docs could be clearer, though of course that’s easier to say than to do.

Definitely true, but a PR that helped to clarify would probably be looked on favorably

---

<div class="post-metadata">

**Author:** ![Ross\_Boylan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ross_boylan/32/9210_2.png) [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Post date:** [May 25, 2019, 2:58am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/12 "2019-05-25T02:58:18Z")

</div>

I opened [[docs] clarify meaning of "project" earlier · Issue #1208 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/issues/1208) about the documentation.

On fuller reading and consideration I’m beginning to suspect the reason the documentation is hard to follow is that the things being documented are a bit of a tangle, with packages, projects and environments all getting in each others’ business.

---

<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:** [May 25, 2019, 11:19am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/13 "2019-05-25T11:19:21Z")

</div>

> [@Ross\_Boylan](#):
>
> the things being documented are a bit of a tangle, with packages, projects and environments all getting in each others’ business.

Another way to say this is that their definitions overlap. I feel like there’s a post by Stefan somewhere that explains it real it well, but the way I think about it is:

- A **project** is a folder with a `Project.toml` file and optionally a `Manifest.toml`.
- **Packages** are a special subset of projects that contain code meant to be used by others, usually invoked by `using`.
- An **environment** is what you get in a Julia session when you `activate` a project.

Not sure if these definitions are consonant with what’s in the docs, but this is how I see it and I think I have a reasonable handle on it (now, after a fair but if confusion starting out).

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [May 27, 2019, 4:37pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/14 "2019-05-27T16:37:19Z")

</div>

Maybe you’re thinking of the glossary?

[https://julialang.github.io/Pkg.jl/v1/glossary/index.html](https://julialang.github.io/Pkg.jl/v1/glossary/index.html)

I originally had that as one of the first things in the documentation since I generally want to understand what terms mean before anything else, but it seems that people found it too technical and now it’s buried kind of deep in the Pkg manual.

Packages and projects are explicitly overlapping: a package is a kind of project (an application is the other kind). Environments are distinct; each project has an environment associated with it but there are other kinds of environments too, which is necessary since you don’t want to have to create a project for any set of packages you might want to use together.

---

<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:** [May 27, 2019, 4:52pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/15 "2019-05-27T16:52:48Z")

</div>

> [@StefanKarpinski](#):
>
> Maybe you’re thinking of the glossary?

That’s certainly helpful, but I have recollection of a discourse or slack post. Then again, I did some digging on discourse and couldn’t find it, so maybe I’m mistaken.

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [May 27, 2019, 7:52pm UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/16 "2019-05-27T19:52:26Z")

</div>

I haven’t found a use case for Applications yet. Is there something explicit inside `Project.toml` that let’s you know whether a project is an Application or a Package?

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [May 28, 2019, 2:07am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/17 "2019-05-28T02:07:55Z")

</div>

Any project that isn’t a package is an application. Presumably you run code sometimes, in which case you have applications.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 28, 2019, 5:55am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/18 "2019-05-28T05:55:12Z")

</div>

> [@StefanKarpinski](#):
>
> Any project that isn’t a package is an application.

What would be the formal criteria for a package? Eg if I have a directory with a `Project.toml`, how could I make a program tell if it is a package?

Is it the presence of a `src/ProjectName.jl`?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 28, 2019, 6:34am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/19 "2019-05-28T06:34:31Z")

</div>

You need `src/ProjectName.jl` and `name` + `uuid` to `using ProjectName` if thats what you meant. Of course, a package environment is also often used as an application.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 28, 2019, 6:57am UTC](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303/20 "2019-05-28T06:57:52Z")

</div>

But if you are not `using ProjectName`, what’s the benefit/purpose of having a `Project.toml` with `name = "ProjectName"` and an UUID?

I also don’t quite understand what applications have to do with the package infrastructure. There is a single mention of the concept in the [glossary](https://julialang.github.io/Pkg.jl/dev/glossary/), but otherwise it is not used, and I have not seen any examples.

Of course I can imagine an application that has its code in a package, and then has some file with

```julia
import ApplicationPackage
ApplicationPackage.run()

```

or something like that as the main entry point. But even in that case, the concept of an application seems orthogonal to the whole Pkg infrastructure — an application is a program (script), that may or may not use a package, but otherwise it is just like any other piece of runnable code.

[Next page](https://discourse.julialang.org/t/recommendations-for-how-to-browse-source-code/24303.md?page=2)
