Suppose one is getting started with Julia, but has made a series of scripts to pass on to someone else, that has just installed julia for the first time on its machine.
Without having to specify which Packages are to be used to make your scripts work, and without say to him nothing on packages he should install to be able to run the scripts … because he is more beginner than you, for example … can you pass to him a “needs.jl” script that will import all the packages you need?
Is such an approach correct, if you say to your friend “write in command line julia.exe needs.jl” to be sure he will have all package installed in his machine?
For example a script of this type, I mean:
println("\n\nThis script will add the necessary packages\nfor the operations, please wait ..\n\n")
But you’ve still convinced me that try-wrapped using is highly brittle rather than “somewhat”.
I suppose if you really wanted to make something self-contained without using PackageCompiler, you could always vendor all dependencies in and just alter DEPOT_PATH at the top of your script. That’s a lot of overhead just to avoid having someone run Pkg.instantiate() though.
Try running it for the second time, it should be much faster. That said, this is not something I would do.
The key problem is that “standalone scripts” are not really a meaningful concept in Julia, as extra information is needed to resolve “simple” code loading like
Depending on the environment, it may not even load the same package (ie different UUID). Casually running a script without this information may just work, or may break, in an fashion that is essentially random (because it depends on global state).
just cd to the folder and start with --project , run import Pkg; Pkg.instantiate() . Done.
A related question:
I am working in an airgapped computer network. I have been trying to develop a package that can be used by all the computers on the network. I would like to have all computers on the network be able to import the package from a git repository on one specific computer.
How do I do this?
I’ve been under the impression that, from any computer, I would add the line push!(LOAD_PATH, "\\\\ComputernamePath\\drive\\collection_of_repos\\my_repo")
to the julia startup script (or run it at the top of a file), then run Pkg.install(my_repo). This doesn’t work.
Frankly, I have no idea how to do this despite substantial time searching.
Would you please elaborate on how to implement both of your potential solutions: (1) create a local registry that mirrors packages; (2) push!(DEPOT_PATH, “location_on_network_drive”).
The workflow I we are currently using (please tell me if there is a better way):
(1) we have a bare repository on one computer.
(2) to develop the repository, each computer has a local repository that pulls from/pushes to the bare repository.
(3) When we have a version for a “package” we are developing, we pull from the bare repository to a single non-bare repository in a folder on one computer containing all packages we are developing (I put “package” in scare quotes because I think I have the appropriate directory structure, .toml file, and such for this module for it to be a valid package, but I frankly don’t know what I am doing).
(4) we would like for all other computers on the network to be able to import this “package”, not for development, but for using on different projects.
A related question:
Because of our airgap, we are currently spending a lot of time manually installing packages on each computer. Is there a way to mirror all julia packages to a computer on the network and have julia installations on each computer look to this mirror for pkg.install("…")? This would save us a lot of time.
Thanks so much!
I should add that if Atom’s project folder is the “package”'s folder, then the following is in fact working:
] activate .