Type problem running old julia codes

In running some old julia code (version 0.6.0), I encountered some error:

LoadError: UndefVarError: `T` not defined

The error comes from this line of code:

function ph_conjugate{T}(psi::Vector{T}, states::HaldaneSphereStatesListLLL)

I suspect that it is because the code is not compatible with the new versions of Julia.

Is it so? If yes, how to modify the code?

1 Like

Yes, this changed going from version 0.6 to 0.7 (which became v1.0). After that the syntax Foo{T}(...) is reserved for type constructors. Regular function signatures must use the where clause like this:

function ph_conjugate(psi::Vector{T}, states::HaldaneSphereStatesListLLL) where {T}

See:

(this link previews the 1.11 release notes, but the link should take you to the correct place)
and

6 Likes

If you just want to run it, you can install Julia 0.6 using:

juliaup add 0.6.0
juliaup default 0.6.0

If you want to port it to a new Julia version, perhaps change the title of your question?

5 Likes

Related to what Uwe is suggesting here, you can try running your code on 0.7 - this should give you deprecation warning for all the things that changed between 0.6 and 0.7, which you can then fix up. Given that 0.7 became 1.0, there’s then a good chance that you can run your fixed up code on 1.11 (modulo breaking changes to packages that you’re using).

6 Likes

But how can I set my default back to the new version?

I am worried about the potential collision between the two versions.

juliaup default 1.11

or

juliaup default release

Or you keep the default to release and just run the old version with:

julia +0.6.0

You can even set defaults per folder:

juliaup override set 0.6.0 

sets a directory override for the current working directory to 0.6.0.

For more info see: GitHub - JuliaLang/juliaup: Julia installer and version multiplexer

3 Likes

where to run such commands?

cmd in windows? It does not work.

not in julia neither.

In the terminal. Of course you must have juliaup installed, otherwise it will not work.

winget install julia -s msstore

will install juliaup on Windows.

1 Like

I have installed juliaup, but encountered another problem

C:\Users\jmzhang>julia add 0.6.0
Installing Julia 1.11.2+0.x64.w64.mingw32
^C
C:\Users\jmzhang>juliaup add 0.6.0
Error: '0.6.0' is not a valid Julia version or channel name.

C:\Users\jmzhang>juliaup add 0.6.0
Error: '0.6.0' is not a valid Julia version or channel name.

C:\Users\jmzhang>julia --version
Error: The Julia launcher failed to figure out which juliaup channel to use.

C:\Users\jmzhang>julia
Error: The Julia launcher failed to figure out which juliaup channel to use.

C:\Users\jmzhang>

Now I cannot even use julia. Possibly because of the mistake in

C:\Users\jmzhang>julia add 0.6.0
Installing Julia 1.11.2+0.x64.w64.mingw32
^C

That’s because 0.6.0 is not a valid channel name:

~> juliaup list                                                                                                                       
 Channel            Version
----------------------------------------------------
 0                  0.7.0+0.x64.w64.mingw32
 0.7                0.7.0+0.x64.w64.mingw32
 0.7.0              0.7.0+0.x64.w64.mingw32
(...)

As I said above, if you are interested in running 0.6 code and using it in more recent, actually supported Julia releases, 0.7 is probably the most helpful version for you.

2 Likes

Just curious, is there a rationale for juliaup only going as far back as 0.7? Considering how many minor versions are in v1 by now, is it much more of a burden to continue supporting more minor versions for v0, just for legacy code? I hadn’t learned Julia then, but a cursory look at old threads’ struggles to adjust to 0.7 would make me port things to v1 instead if the matching version is no longer an easy option.

At least on Linux, juliaup can install versions back to 0.3.

You typed julia add 0.6.0, but you need to type juliaup add 0.6.0.

Works fine on Linux:

ufechner@framework:~$ juliaup add 0.6.0
Installing Julia 0.6.0+0.x64.linux.gnu
ufechner@framework:~$ julia +0.6.0
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0 (2017-06-19 13:05 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> 

I just checked, and on Windows indeed 0.7.0 is the oldest available Julia version. Perhaps your code works on 0.7.0 ?

I created a bug report: Julia 0.6.0 not available on Windows · Issue #1132 · JuliaLang/juliaup · GitHub

2 Likes

Maybe irrelavant to this thread, but I just realise that a similar case indeed exists in python. While there are still some people using python 2.x, has anyone here worked with python 1.x or python 0.x? I believe they are no longer maintained now, though you can still get some of them, like here for 0.9.1.
My point is similar to Benny. Newer programming languages like python or Julia seem to put less emphasis on backward compatibility than old ones like Fortran, and according to Semantic Versioning, the major version number is indeed reserved for this purpose (backward incompatibility). Besides, “Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.”

In short:

  1. It may not be a good idea to stick to legacy codes written in 0.x versions. It may be better to port them to newer versions.
  2. For legacy code in 1.x versions and above, it may still be better to port them if the major version number have differed by larger than 1. For example, with Python 3 the current version, those code written in Python 1 should be ported instead of maintained. Luckily, Julia is still in 1.x and there are no such problems.

Unluckily, there may be much more codes written with Julia pre-1.0 than with python pre-2.0. I think the author of this thread has posed quite a lot of related problems in the forum, and I’m somehow curious about how large his legacy code base is.

1 Like

That’s a surprise but I can reproduce this:

~> juliaup add 0.6.0                                                                                                                                                                         
Error: '0.6.0' is not a valid Julia version or channel name.

~> juliaup add 0.7.0                                                                                                                                                                       
Installing Julia 0.7.0+0.x64.w64.mingw32

~> ubuntu                                                                                                                                                                                    
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)

ngudat@PC-PW0AKFMK:~$ juliaup add 0.6.0
Installing Julia 0.6.0+0.x64.linux.gnu

I maintain my recommendation of installing 0.7 though (and even if you go for 0.6, just to 0.6 and not 0.6.0, no reason not to use the latest patch release)

For what it’s worth I cannot reproduce:

$ juliaup add 0.6.0
Installing Julia 0.6.0+0.x64.linux.gnu

Very odd - I thought maybe my juliaup was out of date, but juliaup self update says no updates available. I also can’t see any way to refresh the list of available versions.

Julia 0.6.0 is available via juliaup for Linux, but not for Windows. Version 0.7.0 is the oldest version available for Windows.

Just to clarify, this is about juliaup. The old releases page seems to have binaries for almost everything (I did not check if the links still work). Interesting that macOS has v0.1, Windows showed up at v0.2, Linux at v0.3, I’d expect the order to be reversed.