Use alternative mirrors to manage your packages for Julia.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
data
src
test
.codecov.yml
.gitignore
.travis.yml
LICENSE.md
Manifest.toml
Project.toml
README-zh_cn.md
README.md
REQUIRE
appveyor.yml

README.md

PkgMirrors

Use alternative mirrors to manage your packages for Julia.

Linux, OSX: Build Status

Windows: Build status

Code Coverage: Coverage Status codecov.io

中文文档

PkgMirrors.jl is a client for boosting your download by using a mirror when you have a slow connection to GitHub (for example, in China).

Current supported mirrors (see mirror_list.txt):

Installation

NOTE: This package will only work with Pkg3, which means you need to run Julia 0.7+ to use it.

There are several ways to install this package:

julia> # Type "]" to enter Pkg REPL-mode.

(v1.0) pkg> add PkgMirrors  # Install from the official registry.

(v1.0) pkg> add https://github.com/sunoru/PkgMirrors.jl  # Install from source code.

(v1.0) pkg> add https://mirrors.zju.edu.cn/julia/PkgMirrors.jl.git@v1.1.0  # Install from the mirror. (Recommended)

You will probably prefer the third way, for it is why you want to use PkgMirrors.jl. The URL can be replaced by that of your preferred mirror. Remove #v1.0.0 if you want to use the developing branch.

Usage

To start with PkgMirrors.jl, import the package and set a mirror for your Pkg.

julia> import PkgMirrors

julia> PkgMirrors.availables()  # to list available mirrors.
2-element Array{String,1}:
 "ZJU"
 "USTC"

julia> PkgMirrors.setmirror("ZJU")  # to set the mirror.
[ Info: Updating mirror information...
[ Info: PkgMirror ZJU activated.
PkgMirrors.PkgMirror("ZJU", "https://mirrors.zju.edu.cn/julia")

It will remember which mirror you have chosen, so there's no need to setmirror for the next time:

julia> import PkgMirrors
[ Info: Using saved mirror: ZJU (https://mirrors.zju.edu.cn/julia)
[ Info: Updating mirror information...
[ Info: PkgMirror ZJU activated.

Once a mirror is selected and activated, you are free to use the standard Pkg to install or update packages. For example:

julia> # Type "]" to enter Pkg REPL-mode.

(v1.0) pkg> update
  Updating registry at `C:\Users\sunoru\.julia\registries\General`
  Updating git-repo `https://mirrors.zju.edu.cn/julia/registries/General.git`
 Resolving package versions...
  Updating `C:\Users\sunoru\.julia\environments\v1.0\Project.toml`
 [no changes]
  Updating `C:\Users\sunoru\.julia\environments\v1.0\Manifest.toml`
 [no changes]

(v1.0) pkg> add RandomNumbers
 Resolving package versions...
  Updating `C:\Users\sunoru\.julia\environments\v1.0\Project.toml`
  [e6cf234a] + RandomNumbers v1.0.1
  Updating `C:\Users\sunoru\.julia\environments\v1.0\Manifest.toml`
  [e6cf234a] + RandomNumbers v1.0.1

You can find that the URL of the git repo for General registry has been modified to the one PkgMirrors.jl provides.

If a package is not on the mirror it will have a fallback to use git clone from GitHub.

When you exit Julia the changes to your registries will be undone automatically:

julia> exit()
[ Info: PkgMirror ZJU deactivated.

You can also deactivate the mirror manually or clear the cache data by a simple statement:

julia> PkgMirrors.deactivate()
[ Info: PkgMirror ZJU deactivated.

julia> PkgMirrors.clear()
[ Info: Cache clear.

New mirror?

See julia-mirror for how to build a mirror. You can file an issue or open a pull request to add a new mirror into the mirror list.

Issues

Known:

  • PkgMirrors.jl is not able to deal with packages not in General registry at the moment. It is not vital yet, since current working mirrors don't provide other registries as well.

You are welcome to file an issue if having any questions.

License

MIT License