# Using a local package

**URL:** https://discourse.julialang.org/t/using-a-local-package/111387
**Category:** General Usage
**Tags:** question
**Created:** [March 9, 2024, 4:42am UTC](https://discourse.julialang.org/t/using-a-local-package/111387 "2024-03-09T04:42:00Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)
#### Post date: [March 9, 2024, 4:42am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/1 "2024-03-09T04:42:00Z")

</div>

I downloaded a [package](https://github.com/yomichi/SpinMonteCarlo.jl) from github, so I have all the source codes.

To run an example code, I have to install the package first using pkg as suggested by the author. However, that failed.

Is it possible to run the code using the local files?

The first line of the example code is

```julia
using SpinMonteCarlo

```

I have copied the example code to the same directory as the file SpinMonteCarlo.jl. But I still got the error:

```julia
ERROR: LoadError: ArgumentError: Package SpinMonteCarlo not found in current path.  
- Run `import Pkg; Pkg.add("SpinMonteCarlo")` to install the SpinMonteCarlo package.

```

How to fix the problem?

---

<div class="post-metadata">

### Author: ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)
#### Post date: [March 9, 2024, 4:55am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/2 "2024-03-09T04:55:13Z")

</div>

[`Pkg.develop`](https://pkgdocs.julialang.org/v1/api/#Pkg.develop)

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [March 9, 2024, 4:57am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/3 "2024-03-09T04:57:51Z")

</div>

> [@jiang\_ming\_zhang](#):
>
> I have to install the package first using pkg as suggested by the author. However, that failed.

Did you try:

```julia
mkdir Spin
cd Spin
julia --project="."

```

and then in Julia

```julia
]
add SpinMonteCarlo

```

Does this work? I get one warning, but no error.  
Quit Julia, restart it with

```julia
julia --project

```

and try again

```julia
using SpinMonteCarlo

```

Does this work? If not, what is the error message?

---

<div class="post-metadata">

### Author: ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)
#### Post date: [March 9, 2024, 5:02am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/4 "2024-03-09T05:02:21Z")

</div>

```julia
julia> using Pkg

julia> Pkg.develop("SpinMonteCarlo")
     Cloning git-repo `https://github.com/yomichi/SpinMonteCarlo.jl.git`
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Rimu [c53c40cc]:
 Rimu [c53c40cc] log:
 ├─possible versions are: 0.6.1-0.11.1 or uninstalled
 ├─restricted to versions * by an explicit requirement, leaving only versions: 0.6.1-0.11.1
 └─restricted by compatibility requirements with SpecialFunctions [276daf66] to versions: uninstalled — no versions left
   └─SpecialFunctions [276daf66] log:
     ├─possible versions are: 0.7.0-2.3.1 or uninstalled
     └─restricted to versions 0 by SpinMonteCarlo [71c4a2d3], leaving only versions: 0.7.0-0.10.3
       └─SpinMonteCarlo [71c4a2d3] log:
         ├─possible versions are: 1.0.0 or uninstalled
         └─SpinMonteCarlo [71c4a2d3] is fixed to version 1.0.0
Stacktrace:
  [1] propagate_constraints!(graph::Pkg.Resolve.Graph, sources::Set{Int64}; log_events::Bool)
    @ Pkg.Resolve C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Resolve\graphtype.jl:1072
  [2] propagate_constraints! (repeats 2 times)
    @ Pkg.Resolve C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Resolve\graphtype.jl:1008 [inlined]
  [3] simplify_graph!(graph::Pkg.Resolve.Graph, sources::Set{Int64}; clean_graph::Bool)
    @ Pkg.Resolve C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Resolve\graphtype.jl:1533
  [4] simplify_graph! (repeats 2 times)
    @ Pkg.Resolve C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Resolve\graphtype.jl:1532 [inlined]
  [5] resolve_versions!(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, julia_version::VersionNumber, installed_only::Bool)
    @ Pkg.Operations C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:407
  [6] targeted_resolve(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, preserve::Pkg.Types.PreserveLevel, julia_version::VersionNumber)
    @ Pkg.Operations C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1360
  [7] tiered_resolve(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, julia_version::VersionNumber, try_all_installed::Bool)
    @ Pkg.Operations C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1349
  [8] _resolve(io::Base.TTY, env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, preserve::Pkg.Types.PreserveLevel, julia_version::VersionNumber)       
    @ Pkg.Operations C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1370
  [9] develop(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, new_git::Set{Base.UUID}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform)
    @ Pkg.Operations C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1410
 [10] develop
    @ Pkg.Operations C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1402 [inlined]
 [11] develop(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; shared::Bool, preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::@Kwargs{io::Base.TTY})
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:225
 [12] develop(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:159
 [13] develop(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:148
 [14] develop
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:147 [inlined]
 [15] develop(pkg::String)
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:146
 [16] top-level scope
    @ REPL[2]:1

```

---

<div class="post-metadata">

### Author: ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)
#### Post date: [March 9, 2024, 5:14am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/5 "2024-03-09T05:14:26Z")

</div>

Since you were asking how to install a package that you already cloned from Github, the relevant parameter for `Pkg.develop` would have been `path`. I would strongly recommend that you start to read documentation and do some basic investigation before asking here.

I do not believe you are installing into a clean environment. In a clean environment, the `SpinMonteCarlo` package installs without problems. Did you try the instructions in [Using a local package - #3 by ufechner7](https://discourse.julialang.org/t/using-a-local-package/111387/3)?

---

<div class="post-metadata">

### Author: ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)
#### Post date: [March 9, 2024, 5:15am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/6 "2024-03-09T05:15:06Z")

</div>

Now I can add the package, but I still cannot use it.

```julia
julia> using SpinMonteCarlo
    Updating registry at `C:\Users\jmzhang\.julia\registries\General.toml`
   Installed Adapt ────────── v4.0.3
   Installed LsqFit ───────── v0.15.0
   Installed FillArrays ───── v0.12.8
   Installed ArrayInterface ─ v7.8.1
   Installed Distributions ── v0.25.45
    Updating `C:\Users\jmzhang\Downloads\SpinMonteCarlo.jl-master\Project.toml`
  [864edb3b] + DataStructures v0.18.18
⌃ [31c24e10] + Distributions v0.25.45
  [2fda8390] + LsqFit v0.15.0
  [1914dd2f] + MacroTools v0.5.13
⌅ [276daf66] + SpecialFunctions v0.10.3
  [10745b16] ~ Statistics ⇒ v1.10.0
    Updating `C:\Users\jmzhang\Downloads\SpinMonteCarlo.jl-master\Manifest.toml`
  [79e6a3ab] + Adapt v4.0.3
  [4fba245c] + ArrayInterface v7.8.1
  [d360d2e6] + ChainRulesCore v1.23.0
  [bbf7d656] + CommonSubexpressions v0.3.0
  [34da2185] + Compat v4.14.0
  [187b0558] + ConstructionBase v1.5.4
  [9a962f9c] + DataAPI v1.16.0
  [864edb3b] + DataStructures v0.18.18
  [b429d917] + DensityInterface v0.4.0
  [163ba53b] + DiffResults v1.1.0
⌃ [b552c78f] + DiffRules v1.14.0
⌃ [31c24e10] + Distributions v0.25.45
  [ffbed154] + DocStringExtensions v0.9.3
⌅ [1a297f60] + FillArrays v0.12.8
  [6a86dc24] + FiniteDiff v2.22.0
  [f6369f11] + ForwardDiff v0.10.36
  [3587e190] + InverseFunctions v0.1.12
⌅ [92d709cd] + IrrationalConstants v0.1.1
  [692b3bcd] + JLLWrappers v1.5.0
  [2ab3a3ac] + LogExpFunctions v0.3.27
  [2fda8390] + LsqFit v0.15.0
  [1914dd2f] + MacroTools v0.5.13
  [e1d29d7a] + Missings v1.1.0
  [d41bc354] + NLSolversBase v7.8.3
  [77ba4419] + NaNMath v1.0.2
  [bac558e1] + OrderedCollections v1.6.3
  [90014a1f] + PDMats v0.11.31
  [21216c6a] + Preferences v1.4.3
  [1fd47b50] + QuadGK v2.9.4
  [189a3867] + Reexport v1.2.2
  [ae029012] + Requires v1.3.0
  [79098fc4] + Rmath v0.7.1
  [efcf1570] + Setfield v1.1.1
  [a2af1166] + SortingAlgorithms v1.2.1
⌅ [276daf66] + SpecialFunctions v0.10.3
  [1e83bf80] + StaticArraysCore v1.4.2
  [82ae8749] + StatsAPI v1.7.0
⌅ [2913bbd2] + StatsBase v0.33.21
⌅ [4c63d2b9] + StatsFuns v0.9.18
  [efe28fd5] + OpenSpecFun_jll v0.5.5+0
  [f50d1b31] + Rmath_jll v0.4.0+0
  [0dad84c5] + ArgTools v1.1.1
  [56f22d72] + Artifacts
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [8ba89e20] + Distributed
  [f43a241f] + Downloads v1.6.0
  [7b1f6079] + FileWatching
  [9fa8497b] + Future
  [b77e0a4c] + InteractiveUtils
  [b27032c2] + LibCURL v0.6.4
  [76f85450] + LibGit2
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [ca575930] + NetworkOptions v1.2.0
  [44cfe95a] + Pkg v1.10.0
  [de0858da] + Printf
  [3fa0cd96] + REPL
  [9a3f8284] + Random
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [2f01184e] + SparseArrays v1.10.0
  [10745b16] + Statistics v1.10.0
  [4607b0f0] + SuiteSparse
  [fa267f1f] + TOML v1.0.3
  [a4e569a6] + Tar v1.10.0
  [8dfed614] + Test
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  [e66e0078] + CompilerSupportLibraries_jll v1.0.5+1
  [deac9b47] + LibCURL_jll v8.4.0+0
  [e37daf67] + LibGit2_jll v1.6.4+0
  [29816b5a] + LibSSH2_jll v1.11.0+1
  [c8ffd9c3] + MbedTLS_jll v2.28.2+1
  [14a3606d] + MozillaCACerts_jll v2023.1.10
  [4536629a] + OpenBLAS_jll v0.3.23+2
  [05823500] + OpenLibm_jll v0.8.1+2
  [bea87d4a] + SuiteSparse_jll v7.2.1+1
  [83775a58] + Zlib_jll v1.2.13+1
  [8e850b90] + libblastrampoline_jll v5.8.0+1
  [8e850ede] + nghttp2_jll v1.52.0+1
  [3f19e933] + p7zip_jll v17.4.0+2
        Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`
Precompiling SpinMonteCarlo
  1 dependency successfully precompiled in 35 seconds. 52 already precompiled.

ERROR: The following 1 direct dependency failed to precompile:

LsqFit [2fda8390-95c7-5789-9bda-21331edee243]

Error: Missing source file for LsqFit [2fda8390-95c7-5789-9bda-21331edee243
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\Types.jl:70
  [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{…}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{…})
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:1656
  [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool})
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:159
  [4] precompile
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:147 [inlined]
  [5] #precompile#114
    @ Pkg.API C:\Users\jmzhang\AppData\Local\Programs\Julia-1.10.0\share\julia\stdlib\v1.10\Pkg\src\API.jl:146 [inlined]
  [6] #invokelatest#2
    @ Base .\essentials.jl:889 [inlined]
  [7] invokelatest
    @ Base .\essentials.jl:884 [inlined]
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1957
  [9] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1806
 [10] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [11] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [12] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1797
 [13] macro expansion
    @ Base .\loading.jl:1784 [inlined]
 [14] macro expansion
    @ Base .\lock.jl:267 [inlined]
 [15] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1747
 [16] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [17] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1740
Some type information was truncated. Use `show(err)` to see complete types.

```

---

<div class="post-metadata">

### Author: ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)
#### Post date: [March 9, 2024, 5:15am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/7 "2024-03-09T05:15:48Z")

</div>

anyway, could you run a script in the ‘example’ directory?

---

<div class="post-metadata">

### Author: ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)
#### Post date: [March 9, 2024, 5:19am UTC](https://discourse.julialang.org/t/using-a-local-package/111387/8 "2024-03-09T05:19:18Z")

</div>

Yes.

```julia
$:~/SpinMonteCarlo.jl> julia
(@v1.10) pkg> activate --temp
(jl_xYmywU) pkg> dev .
julia> include("example/simple.jl")

```

Or if you prefer the more explicit version, from a folder `Spin` that contains a clone of `SpinMonteCarlo.jl`:

```julia
$:~/Spin> julia --project=.
julia> using Pkg
julia> Pkg.develop(path="SpinMonteCarlo.jl")
julia> include("SpinMonteCarlo.jl/example/simple.jl")

```
