<div dir="ltr"><div dir="ltr">I think that there’s something more going on, because most of this shouldn’t<br>be necessary, and some of it shouldn’t be in $PATH at all (like<br>/opt/local/share/man; that belongs in $MANPATH). In `~/.bashrc`, you should<br>be specifying something like:<br><br>```bash<br>export PATH=$HOME/bin:/opt/local/bin:/opt/local/sbin:/usr/X11/bin:$PATH<br>```<br><br>In `~/.bash_profile`, you should be doing something like:<br><br>```bash<br>[[ -s $HOME/.bashrc ]] && source $HOME/.bashrc<br>```<br><br>See<br><a href="https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html">https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html</a>,<br>but in general, Terminal.app launches `/bin/bash -i`, not `/bin/bash<br>--login`, which means that `~/.bash_profile` wouldn’t be loaded.<br><br>It should be unnecessary to add<br>`/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin` anywhere, because those<br>should be coming from core configuration (I think that it might be<br>/etc/environment in older versions of macOS). Strictly speaking,<br>/opt/local/sbin should be *before* /usr/local/sbin and /usr/sbin, but<br>*after* everything else.<br><br>Back when I was using zsh (I’m using fish now), I had functions to help me<br>do this[1]. It would be possible to have similar functions for bash,<br>although you’d probably be using `sed` to clean up some values. It would<br>also be instructive to look at what chruby is doing for path reset to remove<br>values[2].<br><br>As far as re-sourcing `~/.bash_profile` because I added or updated<br>functions, I would usually *not* put them in `~/.bash_profile` or<br>`~/.bashrc`, but in a `~/.bashrc.d/` directory that `~/.bashrc` would source<br>with:<br><br>```bash<br>for src in "$HOME/.bashrc.d/*"; do<br>  [[ -s "${src}" ]] && source "${src}"<br>done<br>```<br><br>Then I could edit those scripts independently and not end up with doubled<br>environment configurations. If I had environment configuration in those<br>sourced scripts, I would *definitely* have guards:<br><br>```bash<br>if ! echo $PATH | grep -q /opt/local/bin; then<br>  PATH=/opt/local/bin:$PATH<br>fi<br>```<br><br>I hope that helps you get things sorted out.<br><br>-a<br><br>[1] <a href="https://github.com/halostatue/ryanb-dotfiles-fork/blob/master/zsh/functions/unique-path">https://github.com/halostatue/ryanb-dotfiles-fork/blob/master/zsh/functions/unique-path</a><br>[2] <a href="https://github.com/postmodern/chruby/blob/master/share/chruby/chruby.sh#L13-L28">https://github.com/postmodern/chruby/blob/master/share/chruby/chruby.sh#L13-L28</a><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 20, 2023 at 1:13 PM <a href="mailto:chilli.namesake@gmail.com">chilli.namesake@gmail.com</a> <<a href="mailto:chilli.namesake@gmail.com">chilli.namesake@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="ltr"></div><div dir="ltr">Also, for whatever reason, Mountain Lion does not source .bash_profile on login. So on that box, I have to source it after I login and whenever I sudo. I guess I could add a script to source it at login, but it's not a big deal.</div><div dir="ltr"><br></div><div dir="ltr"><br><blockquote type="cite">On Mar 20, 2023, at 13:10, <a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"></div><div dir="ltr">Really? Do you never edit your .bash_profile to add functions?</div><div dir="ltr"><br><blockquote type="cite">On Mar 20, 2023, at 13:01, Will Senn <<a href="mailto:will.senn@gmail.com" target="_blank">will.senn@gmail.com</a>> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr">
  
    
  
  
    <div>bash_profile is executed for login
      shells, so it shouldn't be sourced more than once per login.<br>
      <br>
      On 3/20/23 11:49 AM, <a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a> wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">I was checking. echo $PATH reports correctly. If I
        source the .bash_profile more than once, however, I get
        duplicates.</div>
      <div dir="ltr"><br>
        <blockquote type="cite">On Mar 20, 2023, at 12:44, Will Senn
          <a href="mailto:will.senn@gmail.com" target="_blank"><will.senn@gmail.com></a> wrote:<br>
          <br>
        </blockquote>
      </div>
      <blockquote type="cite">
        <div dir="ltr">
          
          <div>Sounds like you should check
            $PATH before and after the change to see what it's actually
            doing. Whatever you want to run, say your version of ruby in
            /some/dir/ruby, needs to appear earlier in the path than the
            system version, say /usr/bin/ruby... period. It's not rocket
            science. However, it's not totally straightforward, either.
            Some updated  command locations require that the shell be
            rehashed after changing the path cuz the shell may cache the
            location - <font face="monospace">hash -r,</font> or
            equivalent. That said, it's usually pilot error messing with
            path.<br>
            <br>
            echo "PATH: $PATH"<br>
            before setting and after to see what's going on. then it's
            just a matter of figuring out which ruby comes first.<br>
            <br>
            Will<br>
            <br>
            On 3/20/23 11:33 AM, <a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a>
            wrote:<br>
          </div>
          <blockquote type="cite">
            
            <div dir="ltr">This is the only way I can get it to work
              right without error</div>
            <div dir="ltr"><br>
            </div>
            <div dir="ltr">
              <div dir="ltr">
                <blockquote type="cite">export
PATH="$PATH:$HOME/bin:/opt/local/bin:/opt/local/sbin:/opt/local/share/man:/usr/X11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"</blockquote>
              </div>
              <div><br>
              </div>
            </div>
            <div dir="ltr">It doesn't like :$PATH at the end</div>
            <div dir="ltr"><br>
            </div>
            <div dir="ltr"><br>
              <blockquote type="cite">On Mar 20, 2023, at 09:27, <a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a>
                wrote:<br>
                <br>
              </blockquote>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                
                <div dir="ltr">I am closer, but my $PATH is still messed
                  up.</div>
                <div dir="ltr"><br>
                </div>
                <div dir="ltr">This in .bash_profile</div>
                <div dir="ltr"><br>
                </div>
                <div dir="ltr">
                  <div dir="ltr">
                    <blockquote type="cite">export
PATH=$HOME/bin:/opt/local/bin:/opt/local/sbin:/opt/local/share/man:/usr/X11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH</blockquote>
                  </div>
                  <div><br>
                  </div>
                  <div>gets me this when I source it</div>
                </div>
                <div dir="ltr"><br>
                </div>
                <div dir="ltr">
                  <blockquote type="cite">
                    <div dir="ltr"><b>env: bash: No such file or
                        directory</b></div>
                    <div dir="ltr">dude@mac:~/Extra/sand$ echo $PATH</div>
                    <div dir="ltr">/Users/dude/bin:/opt/local/bin:/opt/local/sbin:/opt/local/share/man:/usr/X11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:</div>
                  </blockquote>
                  <div><br>
                  </div>
                </div>
                <div dir="ltr">notice the trailing ":" </div>
                <div dir="ltr">removing it gets me a no such directory
                  error for "/sbin$PATH"</div>
                <div dir="ltr"><br>
                </div>
                <div dir="ltr"><br>
                  <blockquote type="cite">On Mar 20, 2023, at 09:04,
                    Mark Anderson <a href="mailto:emer@emer.net" target="_blank"><emer@emer.net></a>
                    wrote:<br>
                    <br>
                  </blockquote>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div dir="ltr">Yeah, this is the answer. You always
                      want `/opt/local/bin/` to be near the start of
                      your path. Only stuff that you specifically want
                      to override MacPorts should be before it.
                      (Examples of things you may want before: RVM or
                      NVM or any of the version managers that put things
                      in your home)
                      <div>
                        <div><br clear="all">
                          <div>
                            <div dir="ltr">
                              <div dir="ltr">
                                <div>Thanks,</div>
                                <div>—Mark<br>
                                  _______________________<br>
                                  Mark E. Anderson <<a href="mailto:emer@emer.net" target="_blank">emer@emer.net</a>><br>
                                </div>
                                <div><a href="https://www.linkedin.com/in/markemer/" target="_blank">Find me on
                                    LinkedIn</a><br>
                                </div>
                              </div>
                            </div>
                          </div>
                          <br>
                        </div>
                      </div>
                    </div>
                    <br>
                    <div class="gmail_quote">
                      <div dir="ltr" class="gmail_attr">On Sat, Mar 11,
                        2023 at 5:57 PM Austin Ziegler <<a href="mailto:halostatue@gmail.com" target="_blank">halostatue@gmail.com</a>>
                        wrote:<br>
                      </div>
                      <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
                        <div dir="auto">
                          <div dir="ltr">
                            <div dir="ltr">
                              <div>Change that to</div>
                              <div><br>
                              </div>
                              <div>export
PATH=$HOME/bin:/opt/local/bin:/opt/local/sbin:/opt/local/share/man:/usr/X11/bin:$PATH</div>
                            </div>
                          </div>
                          <br>
                          <div dir="ltr">
                            <div><span>-a</span></div>
                          </div>
                          <div dir="ltr"><br>
                            <blockquote type="cite">On Mar 11, 2023, at
                              14:03, <a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a>
                              wrote:<br>
                              <br>
                            </blockquote>
                          </div>
                          <blockquote type="cite">
                            <div dir="ltr">
                              <div dir="ltr">Thank you, I will check
                                that</div>
                              <div dir="ltr"><br>
                              </div>
                              <div dir="ltr">I have</div>
                              <div dir="ltr"><br>
                              </div>
                              <div dir="ltr">
                                <blockquote type="cite">export
PATH=$PATH:$HOME/bin:/opt/local/bin:/opt/local/sbin:/opt/local/share/man:/usr/X11/bin</blockquote>
                              </div>
                              <div dir="ltr"><br>
                              </div>
                              <div dir="ltr">in my .bash_profile, but
                                echo $PATH shows what you expected:</div>
                              <div dir="ltr"><br>
                              </div>
                              <div dir="ltr">
                                <blockquote type="cite">
                                  <div dir="ltr">dude@mac:~$ echo $PATH</div>
                                  <div dir="ltr">/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dude/bin:/opt/local/bin:/opt/local/sbin...</div>
                                </blockquote>
                                <div dir="ltr"><br>
                                </div>
                                <div dir="ltr">ok, I have something new
                                  to work out.</div>
                              </div>
                              <div dir="ltr"><br>
                                <blockquote type="cite">On Mar 11, 2023,
                                  at 13:49, Austin Ziegler <<a href="mailto:halostatue@gmail.com" target="_blank">halostatue@gmail.com</a>>
                                  wrote:<br>
                                  <br>
                                </blockquote>
                              </div>
                              <blockquote type="cite">
                                <div dir="ltr">
                                  <div dir="ltr">No problem. The system
                                    ruby showing up instead of
                                    MacPorts-installed Ruby would be
                                    *probably* because your $PATH has
                                    `/opt/local/bin` *after* `/usr/bin`.
                                    Typically, one wants to have
                                    Macports (or other third-party
                                    package systems) *before*
                                    /usr/local/bin and /usr/bin.
                                    <div><br>
                                    </div>
                                    <div>-a</div>
                                  </div>
                                  <br>
                                  <div class="gmail_quote">
                                    <div dir="ltr" class="gmail_attr">On
                                      Sat, Mar 11, 2023 at 1:46 PM <a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a>
                                      <<a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a>>
                                      wrote:<br>
                                    </div>
                                    <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
                                      <div dir="auto">
                                        <div dir="ltr">
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">
                                            <blockquote type="cite">
                                              <div dir="ltr">root@mac:~$
                                                ruby -S gem install
                                                coltrane</div>
                                              <div dir="ltr">ERROR:
                                                 Error installing
                                                coltrane:</div>
                                              <div dir="ltr">
                                                activesupport requires
                                                Ruby version >=
                                                2.7.0.</div>
                                            </blockquote>
                                          </div>
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">Unfortunately,
                                            Mojave:</div>
                                          <div dir="ltr">ruby 2.3.7p456
                                            (2018-03-28 revision 63024)
                                            [universal.x86_64-darwin18]</div>
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">So I install
                                            ruby 2.7.7</div>
                                          <br>
                                          <div dir="ltr">
                                            <blockquote type="cite"><span style="color:rgb(0,0,0)">root@mac:~$
                                                port -vsN install ruby27</span></blockquote>
                                          </div>
                                          <blockquote type="cite">
                                            <div dir="ltr">....</div>
                                            <div dir="ltr">
                                              <div dir="ltr">--->
                                                 Cleaning ruby27</div>
                                              <div dir="ltr">--->
                                                 Removing work directory
                                                for ruby27</div>
                                              <div dir="ltr">--->
                                                 Updating database of
                                                binaries</div>
                                              <div dir="ltr">--->
                                                 Scanning binaries for
                                                linking errors</div>
                                              <div dir="ltr">--->  No
                                                broken files found.</div>
                                              <div dir="ltr">--->  No
                                                broken ports found.</div>
                                              <div dir="ltr">--->
                                                 Some of the ports you
                                                installed have notes:</div>
                                              <div dir="ltr"> ruby27 has
                                                the following notes:</div>
                                              <div dir="ltr"> To make
                                                this the default Ruby
                                                (i.e., the version run
                                                by the 'ruby', 'gem' or
                                                'bundle' commands), run:</div>
                                              <div dir="ltr"> sudo port
                                                select --set ruby ruby27</div>
                                              <div dir="ltr">root@mac:~$
                                                port select --set ruby
                                                ruby27</div>
                                              <div dir="ltr">Selecting
                                                'ruby27' for 'ruby'
                                                succeeded. 'ruby27' is
                                                now active.</div>
                                              <div dir="ltr">root@mac:~$
                                                ruby -S gem install
                                                coltrane</div>
                                              <div dir="ltr">ERROR:
                                                 Error installing
                                                coltrane:</div>
                                              <div dir="ltr">
                                                activesupport requires
                                                Ruby version >=
                                                2.7.0.</div>
                                            </div>
                                          </blockquote>
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">grrr... it's
                                            still trying to use
                                            /usr/bin/ruby</div>
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">but</div>
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">
                                            <blockquote type="cite">
                                              <div dir="ltr">
                                                <div dir="ltr">root@mac:~$
                                                  /opt/local/bin/ruby -S
                                                  gem install coltrane</div>
                                              </div>
                                            </blockquote>
                                            <br>
                                          </div>
                                          <div dir="ltr">installed it.</div>
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">idky my ruby
                                            $PATH seems stuck on
                                            /usr/bin/ruby, but thanks to
                                            your tip, I was able to
                                             install coltrane, and it
                                            seems to be working. Neato
                                            CLI music utility.</div>
                                          <div dir="ltr"><br>
                                          </div>
                                          <div dir="ltr">Thank you,
                                            Austin!</div>
                                          <div dir="ltr"><br>
                                            <blockquote type="cite">On
                                              Mar 11, 2023, at 13:14,
                                              Austin Ziegler <<a href="mailto:halostatue@gmail.com" target="_blank">halostatue@gmail.com</a>>
                                              wrote:<br>
                                              <br>
                                            </blockquote>
                                          </div>
                                          <blockquote type="cite">
                                            <div dir="ltr">
                                              <div dir="ltr">I don’t use
                                                Macports Ruby (I use
                                                `ruby-install`), but try
                                                this:
                                                <div><br>
                                                </div>
                                                <div>sudo ruby -S gem
                                                  install coltrane</div>
                                                <div><br>
                                                </div>
                                                <div>Ruby since Ruby 2.x
                                                  has included Rubygems,
                                                  and since a bit later
                                                  than that, Bundler.</div>
                                                <div><br>
                                                </div>
                                                <div>-a</div>
                                              </div>
                                              <br>
                                              <div class="gmail_quote">
                                                <div dir="ltr" class="gmail_attr">On
                                                  Sat, Mar 11, 2023 at
                                                  1:06 PM <a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a> <<a href="mailto:chilli.namesake@gmail.com" target="_blank">chilli.namesake@gmail.com</a>> wrote:<br>
                                                </div>
                                                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
                                                  <div dir="auto">Hi,
                                                    <div>I need a quick
                                                      ruby primer,
                                                      please.</div>
                                                    <div><br>
                                                    </div>
                                                    <div>I'd like to
                                                      install this,</div>
                                                    <div><a href="https://github.com/pedrozath/coltrane" target="_blank">https://github.com/pedrozath/coltrane</a></div>
                                                    <div><br>
                                                    </div>
                                                    <div>
                                                      <blockquote type="cite">sudo
                                                        gem install
                                                        coltrane</blockquote>
                                                    </div>
                                                    <div><br>
                                                    </div>
                                                    <div>won't work
                                                      because I'm on
                                                      Mojave with an an
                                                      ancient ruby and
                                                      this requires ruby
                                                      2.7 or above.</div>
                                                    <div><br>
                                                    </div>
                                                    <div>
                                                      <blockquote type="cite">sudo
                                                        port -vsN
                                                        install ruby</blockquote>
                                                    </div>
                                                    <div><br>
                                                    </div>
                                                    <div>installs ruby18
                                                      by default</div>
                                                    <div><br>
                                                    </div>
                                                    <blockquote type="cite">
                                                      <div>sudo port
                                                        -vsN install
                                                        ruby27</div>
                                                      <div>sudo port
                                                        select --set
                                                        ruby ruby27</div>
                                                    </blockquote>
                                                    <div><br>
                                                    </div>
                                                    <div>installs, but
                                                      gem still
                                                      complains.</div>
                                                    <div><br>
                                                    </div>
                                                    <div>just guessing
                                                      at this point:</div>
                                                    <div>
                                                      <blockquote type="cite">port
                                                        -vsN install
                                                        rb-rubygems</blockquote>
                                                    </div>
                                                    <div><br>
                                                    </div>
                                                    <div>reinstalls
                                                      ruby18 ><</div>
                                                    <div><br>
                                                    </div>
                                                    <div><br>
                                                    </div>
                                                    <div>Help, please.</div>
                                                  </div>
                                                </blockquote>
                                              </div>
                                              <br clear="all">
                                              <div><br>
                                              </div>
                                              <span>-- </span><br>
                                              <div dir="ltr">Austin
                                                Ziegler • <a href="mailto:halostatue@gmail.com" target="_blank">halostatue@gmail.com</a> • <a href="mailto:austin@halostatue.ca" target="_blank">austin@halostatue.ca</a><br>
                                                <a href="http://www.halostatue.ca/" target="_blank">http://www.halostatue.ca/</a> • <a href="http://twitter.com/halostatue" target="_blank">http://twitter.com/halostatue</a></div>
                                            </div>
                                          </blockquote>
                                        </div>
                                      </div>
                                    </blockquote>
                                  </div>
                                  <br clear="all">
                                  <div><br>
                                  </div>
                                  <span>-- </span><br>
                                  <div dir="ltr">Austin Ziegler • <a href="mailto:halostatue@gmail.com" target="_blank">halostatue@gmail.com</a>
                                    • <a href="mailto:austin@halostatue.ca" target="_blank">austin@halostatue.ca</a><br>
                                    <a href="http://www.halostatue.ca/" target="_blank">http://www.halostatue.ca/</a>
                                    • <a href="http://twitter.com/halostatue" target="_blank">http://twitter.com/halostatue</a></div>
                                </div>
                              </blockquote>
                            </div>
                          </blockquote>
                        </div>
                      </blockquote>
                    </div>
                  </div>
                </blockquote>
              </div>
            </blockquote>
          </blockquote>
          <br>
        </div>
      </blockquote>
    </blockquote>
    <br>
  

</div></blockquote></div></div></blockquote></div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Austin Ziegler • <a href="mailto:halostatue@gmail.com" target="_blank">halostatue@gmail.com</a> • <a href="mailto:austin@halostatue.ca" target="_blank">austin@halostatue.ca</a><br><a href="http://www.halostatue.ca/" target="_blank">http://www.halostatue.ca/</a> • <a href="http://twitter.com/halostatue" target="_blank">http://twitter.com/halostatue</a></div></div>