JuliaLang / juliaup

Julia installer and version multiplexer
MIT License
982 stars 83 forks source link

canonicalize the current_exe result when self updating, so that it works with symlinking. #886

Closed ghyatzo closed 1 month ago

ghyatzo commented 5 months ago

Fixes #885,

It centralises the resolution of the self path into a single function. Consolidated all the locations which queried the self path to call that function for better maintainability and consistency.

this change could also help towards #844, giving better support to symlinks and therefore custom locations

ghyatzo commented 5 months ago

An Issue I encounter with that approach is that the juliaupselfbin which would be the parent folder to get_juliaup_path(), is locked behind the selfupdate feature, and so, not available in all places where access to the self path is required (i.e.: in the install_version function in the operations.rs file).

Another issue is that that would require passing the GlobalPaths object to many functions that as of now do not require it and would need to get their signature updated:

are all functions that would need to change signature for them to use the GlobalPaths object.

Now that I dig a bit more in depth, I noticed also some inconsistencies on how the program refers to its own bin folder: there is in use the functionget_bin_dir() (from #165) for some symlink operations, which searches an env variable JULIAUP_BIN_DIR or defaults to the parent of the binary if and only if the bin dir is within the user home folder. But in the GlobalPaths object we refer to the bin folder only as the parent of the executable (it was also like that before my changes).

It would very much be convenient to standardise this, so that there is only one "authority" that tells us which is the bin folder. From my point of view there are three possibilities:

Personally I think that the most robust option is using JULIAUP_DEPOT_PATH as the only authority if juliaup get's installed in a non default location. It makes little sense to have both JULIAUP_DEPOT_PATH and JULIAUP_BIN_DIR, and at that point we could also get rid of all current_exe() calls. then

But it could be breaking for some (probably only those using JULIAUP_BIN_DIR, which isn't even documented).

Unless I am missing something foundamental, I don't really see why we should ever have juliauphome != juliaupselfhome (which would require keeping the reference to the current_exe)

ghyatzo commented 2 months ago

@davidanthoff bump? any news regarding my comment above and/or your version in #915 ? Shall I close this?

ghyatzo commented 1 month ago

Refer to #915