topgrade-rs / topgrade

Upgrade all the things
GNU General Public License v3.0
2.07k stars 141 forks source link

refactor: disable julia startup file for julia package update #983

Closed Laura7089 closed 6 days ago

Laura7089 commented 1 week ago

What does this PR do

This PR adds the --startup-file=no argument to the julia invocation for updating Julia packages. See the upstream doc.

This is useful because if Julia has been recently updated (eg. with the juliaup step), then old versions of packages configured with using directives in ~/.julia/config/startup.jl may fail to precompile or load with the new version, in turn causing the package update step to fail unnecessarily. By skipping the startup file load, broken or outdated packages will not attempt to be loaded.

Standards checklist

SteveLauC commented 1 week ago

Hi, thanks for the PR!

I would like to know if it would affect the update in other cases by not loading this startup.jl file?

SteveLauC commented 1 week ago

Sorry for accidentally closing the PR. 😵‍💫

Laura7089 commented 1 week ago

It's difficult to answer that - there are almost certainly cases where people have unusual configuration in that file without which their Julia interpreter wouldn't work, but I'd confidently guess that the using-breakage case is much more common since that's a basic function of the feature. If any breakage is a concern, perhaps it could be gated behind a configuration flag?

SteveLauC commented 1 week ago

Thanks for the explanation!

If any breakage is a concern, perhaps it could be gated behind a configuration flag?

Yeah, adding a configuration entry for this makes sense:

[julia]
# If true, Topgrade will pass the `--startup-file=yes` option to Julia when updating it.
#
# <!!!Here, please add the use case where this option would be helpful!!!>
# startup_file = false

We need a new [julia] section, and a startup_file (you can use other names if you prefer) config entry in the example config file. This new section will be added to this struct ConfigFile type, you can add such a helper function to struct Config to make accessing this config easier.

Laura7089 commented 1 week ago

I've set the flag to default to true to mimic retain the (current at time of writing) default behaviour of julia. Is this appropriate or should we prefer the "fixed" case?

SteveLauC commented 1 week ago

or should we prefer the "fixed" case?

Emm, what does the fixed case look like? You mean the change presented in this commit? I am not a user of Julia, but based on our discussion, making it configurable and don't change the current behavior is generally preferred, just in case.