Skip to content

Commit a5fd590

Browse files
authored
add missing subdir instruction (#2703)
1 parent b2ced4b commit a5fd590

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/src/managing-packages.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,38 @@ For example, the tracked dependencies can be stored inside of the active project
208208
The whole directory can be moved and `Pkg` will still be able to find the dependencies
209209
because their path relative to the active project is preserved even though their absolute path has changed.
210210

211+
### Adding a package in a subdirectory of a repository
212+
213+
If the package you want to add by URL is not in the root of the repository, then you need to manually pass the `subdir` keyword to `Pkg.add`
214+
or `PackageSpec`. For instance, to add the `SnoopCompileCore` package in the [SnoopCompile](https://github.com/timholy/SnoopCompile.jl)
215+
repository:
216+
217+
```julia-repl
218+
julia> Pkg.add(url="https://github.com/timholy/SnoopCompile.jl.git", subdir="SnoopCompileCore")
219+
Cloning git-repo `https://github.com/timholy/SnoopCompile.jl.git`
220+
Updating git-repo `https://github.com/timholy/SnoopCompile.jl.git`
221+
Resolving package versions...
222+
Updating `~/.julia/environments/v1.6/Project.toml`
223+
[e2b509da] + SnoopCompileCore v2.7.0 `https://github.com/timholy/SnoopCompile.jl.git:SnoopCompileCore#master`
224+
Updating `~/.julia/environments/v1.6/Manifest.toml`
225+
[e2b509da] + SnoopCompileCore v2.7.0 `https://github.com/timholy/SnoopCompile.jl.git:SnoopCompileCore#master`
226+
[9e88b42a] + Serialization
227+
```
228+
229+
Another way is to use the Pkg REPL with `<repo_url>:<subdir>` format:
230+
231+
```julia-repl
232+
pkg> add https://github.com/timholy/SnoopCompile.jl.git:SnoopCompileCore # git HTTPS protocol
233+
...
234+
235+
pkg> add "[email protected]:timholy/SnoopCompile.jl.git":SnoopCompileCore # git SSH protocol
236+
...
237+
```
238+
239+
!!! compat "Julia 1.5"
240+
The Pkg REPL for packages in subdirectory requires at least Julia 1.5.
241+
242+
211243
## Removing packages
212244

213245
Packages can be removed from the current project by using `pkg> rm Package`.

0 commit comments

Comments
 (0)