Hi,
my company works behind a proxy and, for security reasons, we have our registry hosted in an internal bitbucket server.
Package installation from github works fine with the proxy set in the ‘startup.jl’ file.
But we need to limit the scope of that configuration so that packages go via proxy and code calls don´t (i.e. HTTP.request(get,..)).
Is there a way to configure the proxy only for the package download from github?
Best regards,
Rodrigo
Here is one possible way. In order to get Pkg to download via HTTP proxy, you should put the the following two lines in your ~/.julia/config/startup.jl file.
ENV["HTTP_PROXY"] = "<proxy>"
ENV["HTTPS_PROXY"] = "<proxy>"
This will set a global proxy, but then it looks like it is possible to set the proxy for HTTP.jl differently. If you change their code example to be an empty string, maybe that would work to disable the proxy.
resp = withenv("http_proxy" => "") do
HTTP.request(:GET, url)
end
I have not tested this, so YMMV. Also, you would probably need to disable the proxy for other web packages individually (e.g. Downloads.jl).
Another option would be to simply set the above variables only when you are planning to add/update packages. You could even make a little update script to run once and a while.
import Pkg
ENV["HTTP_PROXY"] = "<proxy>"
ENV["HTTPS_PROXY"] = "<proxy>"
Pkg.update()
Others may have better solutions, but that is all I can think of
This needs a bit more context why you need to install packages from GitHub rather than through Julia’s package servers. (There are a number of possible reasons but understanding which ones apply would make it easier to give advice.)
Thanks but I need to provide a solution valid for my company users, so they don´t access internet via proxy. Telling them to disable it via code is not possible.
Regarding GitHub access. Julia registry is hosted in github ( GitHub - JuliaRegistries/General: The official registry of general Julia packages ), and each package within the registry is pointing to its corresponding package project in github as well.
For instance, this is the content of Pluto’s Package.toml in the General registry:
Blockquote
name = “Pluto”
uuid = “c3e4b0f8-55cb-11ea-2926-15256bba5781”
repo = “https://github.com/fonsp/Pluto.jl.git”
Blockquote
The default way to install packages and the General registry (unless you have a really old Julia version) is through package servers, with GitHub installations as a fallback if the package servers fail.
Presumably your proxy blocks https://pkg.julialang.org and the easiest solution would be to unblock it, which would only give access to public Julia packages, artefacts, and the General registry. Then there should be no need to download packages from GitHub.