fsquillace / junest

The lightweight Arch Linux based distro that runs, without root privileges, on top of any other Linux distro.
GNU General Public License v3.0
2.08k stars 111 forks source link

Update PATH variable without duplicating entries #304

Closed cosmojg closed 1 year ago

cosmojg commented 1 year ago

Since common.sh is called every time that JuNest is run, the current implementation ends up cluttering the PATH variable with duplicate entries, making it far more difficult for end users to manage their PATH variables themselves. This commit solves that problem by prepending necessary paths with a function that deletes them if they are already present, effectively promoting them rather than duplicating them.

cosmojg commented 1 year ago

To clarify, this is what I see with the existing implementation:

cosmo@junest:~$ echo $PATH
/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:/home/cosmo/.local/bin:/home/cosmo/bin:/home/cosmo/.local/bin:/home/cosmo/.local/share/junest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/cosmo/.junest/usr/bin_wrappers:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

And this is what I see after applying my commit:

cosmo@junest:~$ echo $PATH
/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:/home/cosmo/.local/bin:/home/cosmo/bin:/home/cosmo/.local/share/junest/bin:/usr/local/sbin:/usr/games:/usr/local/games:/snap/bin:/home/cosmo/.junest/usr/bin_wrappers:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
cosmojg commented 1 year ago

@fsquillace Not sure why the build is failing. Do I need to provide Docker credentials somehow?

fsquillace commented 1 year ago

Thanks @cosmojg this should be solved given that PATH will not be affected when accessing to JuNest with this change: https://github.com/fsquillace/junest/commit/9b00c5c4c51c513b09ae32b97a0fbd8ca8590d45

cosmojg commented 1 year ago

Ooh, that definitely seems like the better way to do it since it avoids the need to add new functions and potentially introduce new bugs.

As always, thank you for all your hard work on maintaining JuNest!