bash-it icon indicating copy to clipboard operation
bash-it copied to clipboard

Fix loading of nvm for brew-installed nvm

Open brianphillips opened this issue 3 years ago • 2 comments

Loading a brew-installed nvm was previously broken. This PR fixes it.

Description

This reverts to the original (working) version from 2017. During the most recent refactor to use the _bash_it_homebrew_check helper method, it was overlooked that ${BASH_IT_HOMEBREW_PREFIX}/nvm.sh is not the equivalent to $(brew --prefix nvm)/nvm.sh since BASH_IT_HOMEBREW_PREFIX is set from brew --prefix instead of brew --prefix nvm.

Motivation and Context

This fixes a regression caused by 65ef8e2e8be9fc6ded3611751725a32548c933c2.

How Has This Been Tested?

I've tested this on my local instance where I have nvm installed via brew.

Screenshots (if appropriate):

N/A

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] If my change requires a change to the documentation, I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • [ ] I have added tests to cover my changes, and all the new and existing tests pass.

brianphillips avatar Aug 30 '22 21:08 brianphillips

TIL some formula can have unique prefixes, which is probably why the formula name is an optional argument to the --prefix option: from manpage

--prefix [--unbrewed] [--installed] [formula ...]
       Display Homebrew´s install path. Default:

       •   macOS Intel: /usr/local

       •   macOS ARM: /opt/homebrew

       •   Linux: /home/linuxbrew/.linuxbrew

       If formula is provided, display the location where formula is or would be installed.

       --unbrewed
              List files in Homebrew´s prefix not installed by Homebrew.

       --installed
              Outputs nothing and returns a failing status code if formula is not installed.

My guess is that this bug pretty much fully invalidates BASH_IT_HOMEBREW_PREFIX and shows that we should be using something like $(brew --prefix --installed $forumula) in its place.

There might be a way to introduce a convenience function like _bash_it_homebrew_prefix that also does the _bash_it_homebrew_check and possibly simplify the call-sites. (I haven't thought this out though and may be wrong)

davidpfarrell avatar Aug 30 '22 23:08 davidpfarrell

@davidpfarrell What's the next step here?

brianphillips avatar Sep 13 '22 15:09 brianphillips