How to adapt julia-1.0 code for julia-1.6

My julia code worked with version 1.0, but not with version 1.6.
Adapting my code to version 1.6 appears to be not as simple as I hoped.
Is there a text that explains how to do it?

If you only used the “public interface” of Julia 1.0 (i.e. what is documented), then it should just work on Julia 1.6. If it does not it is a bug and should be reported.

If you use Julia’s internals, then things can break from one version to another. A good example is https://github.com/JuliaTesting/TestEnv.jl, which has custom code for each julia version, because it needs to hook into a unstable, internal interface.

I don’t think there are any text around explaining what to do, but I might be wrong. I would recommend to go one Julia version at the time, i.e. 1.0->1.1->1.2, etc.

Without seeing code examples, errors, etc., it will probably be hard to give you more specific advice.

Ah, one more thing which comes to mind: are your errors with Julia or with packages that you use? If the latter, restricting the packages to the versions installed on Julia 1.0 may solve your errors.

1 Like

I left my Julia code at the end of 2018 (was that about version 1.0?), and now come back with Julia 1.7.2. The code had many modules which I recently turned to packages. I basically just fix the errors I encouter when running parts of the code. Fortunately, there aren’t too many incompatibles.

To add to Mauro’s excellent answer, I know you aren’t too keen on using environments but this is exactly the situation which environments aim to prevent.

If your code has an accompanying environment with a Manifest file, you are able to exactly replicate this environment including all dependencies when you later want to run it.

The issues seen in your other threads were things like DataFrames deprecating the df[:x] syntax for accessing columns - if you had used an environment, your code would just install the appropriate (outdated) DataFrames version which allows this column indexing, and your code would work.

3 Likes

I should like to use an environment, but I don’t know how to create one. For instance, what is a “manifest file”?

See:

  1. 2. Getting Started · Pkg.jl
  2. 3. Managing Packages · Pkg.jl
  3. 10. Project.toml and Manifest.toml · Pkg.jl
4 Likes

Apart from the other advice links, one way

mkdir MyShinyProject
cd MyShinyProject
julia -q --project=.
julia> ]
(MyShinyProject) ] add DataFrames CSV
...
(MyShinyProject) ] add /path/ModuleA /path/ModuleB
...
2 Likes

I’ve gone through all this, but I’m not sure I understand all of it. Notably, it seems to me that it is assumed that there are packages to be managed, but I don’t have any packages. However I might well misinterprete this bit.

so you just have a script? can you share the script?

Indeed if you are not using any packages then there is no point in having environments.

However in that case I also wonder why your code isn’t running on Julia 1.6 if it is running on 1.0 - Julia follows semantic versioning, which means that there should be no breaking changes between versions. This only applies to the public API (loosely, exported and documented functionality), so it might be that you are using some undocumented Julia internals, but we’d have to see concrete reproducible examples of the errors you are running into to help with that.

1 Like

I would like to follow your advice, but should I first restructure my code so that I have modules?

No. You do not need to re-structure your code so you have modules. Scripts are fine in Julia. But having things in their own directory with their own toml files is important.

Maybe you could show us some code excerpt that is failing and how it is failing? BTW, we call this a M(inimal)W(orking)E(xample) around here…

Edit: @jjdegruijter: I believe you are following this up here. Can we close this thread then?

No, it’s fine. Environments are where it’s at, instead of adding every package to the base installation.

Packages are for separating concerns, and making unit tests, and invoking GitHub actions to test against other versions and produce documentation.

It is definitely something worth learning - when you have the spare capacity.

I think this thread has gotten a bit off track - really Mauro’s initial answer was all you need to know.

If you aren’t using packages, code should generally work between minor Julia versions (i.e. 1.0, 1.1, etc up to the upcoming 1.8). If something doesn’t work please provide a reproducible example of the error you’re seeing and people will be happy to help you.

2 Likes