ruby_select is broken

Ian Wadham iandw.au at gmail.com
Sun Oct 3 20:16:55 UTC 2021


Hi Christopher,

In brief, MacPorts’ “port select” command is working fine at the command-line in Catalina… but the problem is with installing ANY version of ruby, not switching between multiple versions of ruby that are already installed.

In a machine where no MacPorts Ruby is installed, the command “sudo port install ruby27” is not working fully.

The package gets installed, but the links /opt/local/bin/ruby -> /opt/local/bin/ruby2.7 and /opt/local/bin/gem -> /opt/local/bin/gem2.7 do not get created automatically. So after installing I always get Apple’s Ruby from /usr/bin when I use a “ruby” or “gem” command. Of course I can use “sudo port select” to fix that, and I have done, but it took me several days of frustration and messing around before I discovered that fact.

I think this is because the port file named “ruby_select”, on which each Ruby port depends, is broken. You can see this port file’s contents using:

     cat $(port file ruby_select)

Compare them to the perl and python “select” files:

     cat $(port file perl_select)
     cat $(port file python_select)

and I hope you (or someone) will see what the problem is.

Cheers,
Ian Wadham.

> On 4 Oct 2021, at 1:12 am, Christopher Nielsen <mascguy at rochester.rr.com> wrote:
> 
>> The ruby_select portile just has:
>> 
>> destroot {
>> 	select::install ruby ${filespath}/base
>> 	select::install ruby ${filespath}/none
>> }
>> 
>> which does not redirect the commands “ruby” or “gem” to the appropriate version when you have installed the port “ruby27” for example. Instead, “which ruby” or “which gem” always finds the Apple version of Ruby, which is now deprecated according to the Catalina Release Notes…
> 
> Hmmm, it’s working fine for me.
> 
> Starting from the default case, where nothing has been selected yet:
> 
> $ ll $(which ruby)
> -r-xr-xr-x  1 root  wheel  restricted,compressed   51K Jul  9 18:40:13 2020 /usr/bin/ruby
> $ ll $(which gem)
> -r-xr-xr-x  1 root  wheel  restricted,compressed  596B Jul 15 17:58:00 2017 /usr/bin/gem
> 
> After selecting ruby30:
> 
> $ sudo port select ruby ruby30
> Selecting 'ruby30' for 'ruby' succeeded. 'ruby30' is now active.
> $ ll $(which ruby)
> lrwxr-xr-x  1 root  admin  -   22B Oct  3 09:54:35 2021 /opt/local/bin/ruby -> /opt/local/bin/ruby3.0
> $ ll $(which gem)
> lrwxr-xr-x  1 root  admin  -   21B Oct  3 09:54:35 2021 /opt/local/bin/gem -> /opt/local/bin/gem3.0
> 
> After selecting ruby27:
> 
> $ sudo port select ruby ruby27
> Selecting 'ruby27' for 'ruby' succeeded. 'ruby27' is now active.
> $ ll $(which ruby)
> lrwxr-xr-x  1 root  admin  -   22B Oct  3 09:55:14 2021 /opt/local/bin/ruby -> /opt/local/bin/ruby2.7
> $ ll $(which gem)
> lrwxr-xr-x  1 root  admin  -   21B Oct  3 09:55:14 2021 /opt/local/bin/gem -> /opt/local/bin/gem2.7
> 
> And finally, after reverting back to no selection:
> 
> $ sudo port select ruby none
> Selecting 'none' for 'ruby' succeeded. 'none' is now active.
> $ ll $(which ruby)
> -r-xr-xr-x  1 root  wheel  restricted,compressed   51K Jul  9 18:40:13 2020 /usr/bin/ruby
> $ ll $(which gem)
> -r-xr-xr-x  1 root  wheel  restricted,compressed  596B Jul 15 17:58:00 2017 /usr/bin/gem
> 
> So this isn’t working for you on macOS Catalina…?



More information about the macports-users mailing list