# Downloading package source code without using its git repo

**URL:** <https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516>\
**Category:** Tooling\
**Created:** [May 23, 2022, 2:20pm UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516 "2022-05-23T14:20:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![julbinb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julbinb/32/3079_2.png) [@julbinb](https://discourse.julialang.org/u/julbinb)\
**Post date:** [May 23, 2022, 2:20pm UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516/1 "2022-05-23T14:20:03Z")

</div>

Is there a way to download the source code of a package (given a version or its SHA) directly, without using the package repo?  
(I could do a git clone and checkout, but if there is a way to get just the source code directly, without additional git metadata, that would be better for my purpose.)

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [May 24, 2022, 6:45am UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516/2 "2022-05-24T06:45:49Z")

</div>

Something like this?

[https://stackoverflow.com/questions/7106012/download-a-single-folder-or-directory-from-a-github-repo#18194523](https://stackoverflow.com/questions/7106012/download-a-single-folder-or-directory-from-a-github-repo#18194523)

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [May 24, 2022, 7:34am UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516/3 "2022-05-24T07:34:03Z")

</div>

You want to download a snapshot then. If you go to the repository page you can find a big green button above the list of files, from there you can download the snapshot, as zip or tar.gz. In the default view of the repository that’d be a snapshot from the tip of the default branch, if you visit a different branch you get the link to download the snapshot of that other branch, the same for a revision or tag page. Snapshots for tags can also be downloaded from the list of tags/releases of the repository

---

<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 24, 2022, 2:23pm UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516/4 "2022-05-24T14:23:39Z")

</div>

Or, of you’re comfortable with the command line, `git clone --depth=1 <url>`

---

<div class="post-metadata">

**Author:** ![julbinb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julbinb/32/3079_2.png) [@julbinb](https://discourse.julialang.org/u/julbinb)\
**Post date:** [May 24, 2022, 2:47pm UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516/5 "2022-05-24T14:47:27Z")

</div>

I was hoping that `Pkg.jl` would already have such functionality somewhere. I couldn’t find that in the docs or by brief skimming of the Pkg source code.

I need to get sources of various Julia packages for analysis, so I am looking for a programmable way of downloading package sources for the given package version.

As some packages are hosted on GitLab, I would need to support (and probably maintain) different patterns for GitHub and GitLab to download snapshots. It’s doable but I’d rather use more disk space and rely on clone/checkout rather than bother with snapshotting from different sources.

And it feels like this task must already be solved in `Pkg.jl` for package installation…

---

<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 24, 2022, 3:54pm UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516/6 "2022-05-24T15:54:12Z")

</div>

If you have the package UUID and the tree hash of a version you can download a snapshot tarball at

```nohighlight
https://pkg.julialang.org/package/$uuid/$tree

```

Not very human friendly but this is how the package manager gets packages and I suspect that you may be doing scripted analysis of source code. This also has the advantage of being perfectly cacheable if you’re maintaining a collection of source trees for analysis.

---

<div class="post-metadata">

**Author:** ![julbinb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julbinb/32/3079_2.png) [@julbinb](https://discourse.julialang.org/u/julbinb)\
**Post date:** [May 24, 2022, 5:42pm UTC](https://discourse.julialang.org/t/downloading-package-source-code-without-using-its-git-repo/81516/7 "2022-05-24T17:42:09Z")

</div>

Oh great, thanks!
