Best way to Re-Install Julia on new computer?

You can put your old Project.toml and Manifest.toml into any folder, activate that environment/folder, then instantiate it. It’s possible that would just work.

The way I should usually do this is.

  1. Copy Project.toml and Manifest.toml into directory “foo”
  2. In Julia,
cd("foo")
using Pkg
pkg"activate ."
pkg"instantiate"

Great!

My package GitHub - ufechner7/PkgHelpers.jl: Helper functions for the Julia package manager might help here:

  • copy the two files in any folder
  • install julia 1.4 with juliaup: juliaup add 1.4 and juliup default 1.4
  • install PkgHelpers with using Pkg; Pkg.add("PkgHelpers")
  • launch your old environment with julia --project
  • type
using PkgHelpers,Pkg
freeze(Pkg)

What this command does is to add the current version numbers of all of your packages to the [compat] section of your Project.toml file .

  • quit Julia and install Julia 1.5
  • run it with julia --project
  • run using Pkg; Pkg.instantiate() and perhaps Pkg.resolve()
  • fix any errors that might pop up
  • and continue that with Julia 1.6, 1.7, 1.8 and 1.9

Better do it step by step, errors are much easier to fix this way.

Hi, thanks for the procedure. I’m trying it out, but I am going in a circle with these errors:
(yes, PolyFit is one of my old packages)
(Pkg.resolve() did not help, gave similar errors)

julia> using PkgHelpers
ERROR: ArgumentError: Package PkgHelpers not found in current path:

  • Run import Pkg; Pkg.add("PkgHelpers") to install the PkgHelpers package.

julia> Pkg.add("PkgHelpers")
Updating registry at C:\Users\phybdb\.julia\registries\General
Updating git-repo https://github.com/JuliaRegistries/General.git
Resolving package versions…
ERROR: expected package PolyFit [097a2a50] to exist at path `C:\Users\phybdb.julia\packages\PolyFit\zPgON````

julia> using PkgHelpers
ERROR: ArgumentError: Package PkgHelpers not found in current path:

  • Run import Pkg; Pkg.add("PkgHelpers") to install the PkgHelpers package.

Stacktrace:
[1] require(::Module, ::Symbol) at .\loading.jl:892```

Are you still on Julia 1.4 ?

If yes, can you instantiate your project?

cd myproject
julia --project
using Pkg; Pkg.instantiate()

Try to install PkgHelpers in the global environment, and put your Project.toml and Manifest.toml in a folder of your choice, called project environment.

To install a package in the global environment run Julia without the parameter --project.

Hi, tried running Julia 1.4.2 in the global environment, got the error message:


julia> Pkg.add("PkgHelpers")
   Updating registry at `C:\Users\phybdb\.julia\registries\General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Pkg [44cfe95a]:
 Pkg [44cfe95a] log:
 ├─possible versions are: 1.4.0 or uninstalled
 └─found to have no compatible versions left with PkgHelpers [a562b63c]
   └─PkgHelpers [a562b63c] log:
     ├─possible versions are: [0.1.0, 0.2.0] or uninstalled
     └─restricted to versions * by an explicit requirement, leaving only versions [0.1.0, 0.2.0]```

Can you try:

Pkg.add(PackageSpec(url="https://github.com/ufechner7/PkgHelpers.jl", rev="main"))

I just relaxed the requirement from Julia 1.6 to 1.4 as minimum.

EDIT: Tried to fix the issues with Julia 1.4. Please, give it another try!

Hi again, I’ve struggled some more with my old code in the new Julia, so I want to get the simplest instructions possible to do the following…

Globally, my new version is Julia 1.10.0. My old code ran perfectly well under Julia 1.4.2. My old computer (with that old Julia) is dead and gone, but I have copies of its last working versions of Manifest.toml and Project.toml. Currently, JuliaPro is gone, so I am now running Julia with Visual Studio Code. I have installed the new Julia with Juliaup, and I have already run the command: juliaup add 1.4.2, and it says: `1.4.2` is already installed. So far, so good.

I created a directory called C:\MyResearchPlace\OldPrograms. In that directory, I placed the key old files: Manifest.toml, Project.toml, and LovelyOldProgram.jl. I will edit that program and place lots of modified versions of it in that same directory.

What I want, is that every time I click on a julia program (.jl) file located inside THAT PARTICULAR DIRECTORY, it opens up in Visual Studio Code, and when I select-all and execute the code, for it to automatically run under Julia 1.4.2, using the packages defined by the Manifest.toml and Project.toml files located in C:\MyResearchPlace\OldPrograms. (Simply placing those files in that directory and clicking on the julia file doesn’t seem to do the trick.)

When I open a julia program in ANY OTHER DIRECTORY, it might as well run under the global Julia 1.10.0 environment, but I don’t care as much.

I’ve seen instructions that relate to starting up Julia with line commands, but that’s not how I do it; I just click on a .jl file, for it to open up in Visual Studio Code, I use Ctrl-a to select all of the code, and then Shift-Enter to execute it all. There’s nowhere to type any line commands.

Thanks again for any information.

In Vscode, hit Ctrl-Shift-P.

Then select “Julia: Start REPL”

I just use the menu command “Terminal-New Terminal” in vscode and then type

julia --project

to get a REPL that uses the Project.toml of the current folder.
To execute a script I use the command include("myscript.jl") in the REPL.

And for switching the Julia version I use:

juliup default 1.10

Installing a new version with juliup add is not sufficient, you also need to activate it.

Finally I dont’t start vscode with a double click on a Julia file. Instead, I launch it using the start menu of Windows or Linux and open a project with the vscode menu entry File-> Open Folder....
And there is the VSCode plugin “Project Manager” that allows you to switch between projects more easily.

1 Like

I think you mean juliaup default 1.10.

Fixed.

Should it not be juliaup default 1.4.2, in a REPL started in the VSCode file from the directory where I’m running the old Julia?

Yes, if you want to use Julia 1.4.2 it should be juliaup default 1.4.2