symlink points to itself or nowhere

Richard L. Hamilton rlhamil at smart.net
Fri Jan 6 18:50:27 UTC 2023


I don’t think that should happen! Certainly a link like that does nothing useful, just causes errors. For example:

sh-3.2$ ln -s bogus bogus
sh-3.2$ ln -s '' bogus2

sh-3.2$ ls -l bogus*
lrwxr-xr-x  1 rlhamil  wheel  5 Jan  6 13:39 bogus -> bogus
lrwxr-xr-x  1 rlhamil  wheel  0 Jan  6 13:40 bogus2 -> 

sh-3.2$ ls -lL bogus*
lrwxr-xr-x  1 rlhamil  wheel  5 Jan  6 13:39 bogus -> bogus
lrwxr-xr-x  1 rlhamil  wheel  0 Jan  6 13:40 bogus2 ->
ls: bogus: Too many levels of symbolic links
ls: bogus2: No such file or directory

Ordinarily you can remove a bad symlink, i.e. per the above example

sh-3.2$ rm bogus bogus2

But I don’t recommend that here (see below).

python3 is optional and a selectable way to provide a default shorter name, and resolves to one of the python 3 versions as shown below:

sh-3.2$ port select --list python3
Available versions for python3:
	none (active)
	python310
	python311
	python34
	python36
	python37
	python38
	python39

sh-3.2$ port select --show python3
The currently selected version for 'python3' is 'none'.

You can choose one of those listed  (including none, to get rid of the links) with something like (with then last argument being one of the above ports that you have installed):

sh-3.2$ sudo port select --set python3 python39

Rather than removing the bad link directly, I’d do

sh-3.2$ sudo port select --set python3 none

(so that any record keeping is also updated, and any other associated links are also cleaned up) I might do that before I did it again with some value other than “none” if I wanted that end result, just to be paranoid.

Only if selecting “none” fails (I don’t know how much error checking is done) would I delete the link with “rm”.



> On Jan 6, 2023, at 1:30 PM, list_email--- via macports-users <macports-users at lists.macports.org> wrote:
> 
> /opt/local/bin/python3 is a symlink that points to itself (Path Finder) or to nowhere (Finder). Is that correct?
> 
> Jerry
> 
> 
> M 480 612 4252
> L 480 839 3708
> 
> 



More information about the macports-users mailing list