Brew older version of mysql not available at cmd line - macos

I've installed mysql 5.7 via brew. The binary files are installed at /usr/local/opt/mysql\#5.7/bin/ however I can't access these files as this location isn't in my path.
Is there a brew way to fix this rather than me making symlinks around the system myself?

The Homebrew way of "fixing" this is to use link --force:
brew link --force mysql#5.7
Alternatively, you can add this location to your $PATH by modifying it in your ~/.bashrc or ~/.bash_profile:
export PATH="$(brew --prefix mysql#5.7):$PATH"

The simple "brew way" to do this is answered here
$ brew info mysql (to get info about the installed versions)
$ brew switch mysql 5.7.21 (to switch to a stable version)

Related

Terminal not recognizing nvm after installed with home brew

I installed nvm via homebrew, but when I run nvm -v or nvm --version form terminal I receive the message command not found: nvm. When I look in finder and cmd+shift+. I can see the ~/.nvm folder.
Initially I did not have a .bash_profile in my user directory, so I added one and the command to recognize nvm per this post:
Brew install nvm. nvm: command not found
However, that did not resolve the issue. I've not had this issue with an nvm install before, What could be going on here?
I am on macOS Catalina 10.15.6
I was facing the same issue after installing nvm. Whenever my iTerm / terminal restarts, nvm is gone.
Steps I followed to make it work.
After installing it, update the Homebrew package list and install NVM.
brew update
brew install nvm
Next, create a directory for NVM.
mkdir ~/.nvm
Now add these lines to ~/.bash_profile ( or ~/.zshrc for macOS Catalina or later)
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
Echoing $NVM_DIR should now return your NVM directory
:$ echo $NVM_DIR
/Users/username/.nvm
Now running nvm -v should return nvm’s options.
To see what Node versions are available to install run:
nvm ls-remote
For me, I just needed the latest point release of Node version 11 so I ran
nvm install 11
After installing you can verify what is installed with
nvm ls
If you have multiple versions and you want to specify which version you would like to use, simply use:
nvm use 11
to use Node version 11.
Switching back to, let’s say, version 12 would be as easy as nvm use 12.
After switching to node version 11, all my packages installed properly.
For my scenario, I was able to fix by uninstalling nvm and then reinstalling via curl, which seems to have worked.
I also created a .zshrc file, which apparently mac OS 10.15 and up needs.
I used the documentation here to uninstall and reinstall:
https://github.com/nvm-sh/nvm#about
.zshrc requirement:
https://github.com/nvm-sh/nvm#troubleshooting-on-macos
The steps I took:
From terminal, run
rm -fr "$NVM_DIR"
Then on the same terminal,
run touch ~/.zshrc
to create a .zshrc file.
Now run
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Finally, run
~/.nvm/nvm.sh

msgmerge on macos Catalina

I am trying to run a unix command line for some i18n work on a project. Using gettext library my issue is about running msgmerge
$ msgmerge
zsh: command not found: msgmerge
I tried brew instal gettext and brew link gettext but with no success. This was working well on my previous machine, but can't make it work on a fresh install.
I can confirm binary is available in /usr/local/opt/gettext/bin/msgmerge.
Fixed. When running brew reinstall gettext, command actually give the answer:
If you need to have gettext first in your PATH run:
echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.zshrc
Export is only triggered when opening a new zsh prompt, PATH was not updated yet and worked when I re-openned a new window.
I tried running this brew link gettext --force, but I was getting:
$ brew install gettext
Warning: gettext 0.20.2 is already installed and up-to-date
To reinstall 0.20.2, run `brew reinstall gettext`
$ brew link gettext --force
Warning: Refusing to link macOS provided/shadowed software: gettext
If you need to have gettext first in your PATH run:
echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile
For compilers to find gettext you may need to set:
export LDFLAGS="-L/usr/local/opt/gettext/lib"
export CPPFLAGS="-I/usr/local/opt/gettext/include"
Then, I just added it to the system path with:
echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile
Related:
https://apple.stackexchange.com/questions/299048/can-not-use-the-gettext-which-is-installed-by-brew
Homebrew refusing to link OpenSSL
How to install gettext on MacOS X
Installed, just not linked

Correct way to install psql without full Postgres on macOS?

Official page do not mention such case. But many users need only psql without a local database (I have it on AWS). Brew do not have psql.
You could also use homebrew to install libpq.
brew install libpq
This would give you psql, pg_dump and a whole bunch of other client utilities without installing Postgres.
Unfortunately since it provides some of the same utilities as are included in the full postgresql package, brew installs it "keg-only" which means it isn't in the PATH by default. Homebrew will spit out some information on how to add it to your PATH after installation. In my case it was this:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
Alternatively, you can create symlinks for the utilities you need. E.g.:
ln -s /usr/local/Cellar/libpq/10.3/bin/psql /usr/local/bin/psql
Note: used installed version instead of 10.3.
Alternatively, you could instruct homebrew to "link all of its binaries to the PATH anyway"
brew link --force libpq
but then you'd be unable to install the postgresql package later.
libpq 11.2
MacOS & zsh or bash
below works
install libpq
brew install libpq
update PATH
if use zsh:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
if use bash:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Homebrew only really has the postgres formula, and doesn't have any specific formula that only installs the psql tool.
So the "correct way" to get the psql application is indeed to install the postgres formula, and you'll see toward the bottom of the "caveats" section that it doesn't actually run the database, it just puts the files on your system:
$ brew install postgres
==> Downloading https://homebrew.bintray.com/bottles/postgresql-9.6.5.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring postgresql-9.6.5.sierra.bottle.tar.gz
==> /usr/local/Cellar/postgresql/9.6.5/bin/initdb /usr/local/var/postgres
==> Caveats
<snip>
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Summary
🍺 /usr/local/Cellar/postgresql/9.6.5: 3,269 files, 36.7MB
Now you can use psql to connect to remote Postgres servers, and won't be running a local one, although you could if you really wanted to.
To verify that the local postgres daemon isn't running, check your installed homebrew services:
$ brew services list
Name Status User Plist
mysql stopped
postgresql stopped
If you don't have Homebrew Services installed, just
$ brew tap homebrew/services
...and you'll get this functionality. For more information on Homebrew Services, read this excellent blog post that explains how it works.
If you truly don't need postgresql then you don't even have to alter your path to use libra, just link libpq. The docs say the only reason it isn't is to avoid conflicts with the PostgreSQL package.
brew uninstall postgresql
brew install libpq
brew link --force libpq
Install libpq:
brew install libpq
Then, create a symlink:
sudo ln -s $(brew --prefix)/opt/libpq/bin/psql /usr/local/bin/psql
Hope it helps.
I found all of these really unsatisfying, especially if you have to support multiple versions of postgres. A MUCH easier solution is to download the binaries here:
https://www.enterprisedb.com/download-postgresql-binaries
And simply run the executable version of psql that matches the database you're working against without any extra steps.
example:
./path/to/specific/version/bin/psql -c '\x' -c 'SELECT * FROM foo;'
Found so many useful answers here, but a bit outdated since homebrew moved the installation files to /opt/homebrew/Cellar/libpq/15.1. After libpq is installed with brew install libpq you can run below command to see new location
brew link --force libpq
Then you can add it to your zshrc with
echo 'export PATH="/opt/homebrew/Cellar/libpq/15.1/bin:$PATH"' >> ~/.zshrc
You could try brew install postgresql
But this provides a nice GUI to manage your databases https://postgresapp.com

Homebrew installs nvm but nvm can't be found afterwards?

I'm using homebrew and oh-my-zsh on a fresh OSX 10.10.1 install. I got nvm via homebrew and then attempted to run it but says - zsh: command not found: nvm
Any idea what the problem is? I was able to install and use git just fine...
UPDATED 9/20/2019
As stated by more recent answers from DarkPurple141 and Elise van Looij. nvm doesn't appear to be compatible with homebrew. This is also stated in the official nvm-sh repo located here.
Homebrew installation is not supported. If you have issues with
homebrew-installed nvm, please brew uninstall it, and install it using
the instructions below, before filing an issue.
Note: If you're using zsh you can easily install nvm as a zsh plugin.
Install zsh-nvm and run nvm upgrade to upgrade.
The following steps should help:
$ brew uninstall nvm
$ brew cleanup (just for good measure)
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
Check that nvm was installed correctly by running $ command -v nvm.
4.a If the response is anything other than $ nvm, add the following two lines to the ~/.bash-profile file:
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
4.b Restart your computer (you can try closing Terminal and restarting it first)
4.c $ command -v nvm should now return nvm`
Now update Node.js with $ nvm install --lts
Update npm: $ nvm install-latest-npm
$ npm install --global mocha. Finally, success! Well, for me and I hope for you too.
Did you follow the instructions listed in the caveats?
[~] brew info nvm
nvm: stable 0.20.0, HEAD
https://github.com/creationix/nvm
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/nvm.rb
==> Caveats
Add the following to $HOME/.bashrc, $HOME/.zshrc, or your shell's
equivalent configuration file:
source $(brew --prefix nvm)/nvm.sh
Node installs will be lost upon upgrading nvm. Add the following above
the source line to move install location and prevent this:
export NVM_DIR=~/.nvm
Without the extra config it doesn't look like it will find NVM by default..
There are TWO things you need to do. Follow the caveats shown after installing nvm via brew, and THEN you need to activate/reload the .bash_profile changes.
Run brew install nvm
Follow caveats shown in console, mine were as follows, yours MAY be different!:
Add the following to ~/.bash_profile or your desired shell
configuration file:
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
Run . ~/.bash_profile to apply the changes you made to your .bash_profile file
I've spent a couple of hours going round and round on this issue, but I've come to the conclusion that DarkPurple141 is right: nvm just isn't compatible with Homebrew, as they state on their Github nvm-sh/nvm Node Version Manager. Homebrew will install nvm and everything looks fine, until one tries to get npm to install a module, Mocha in my case. That threw me right back to the dreaded error:
ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
NOTE: On step 3, make sure to replace version with correct release.
The solution, on MacOS 10.14 Mojave, was:
$ brew uninstall nvm
$ brew cleanup (just for good measure)
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
Check that nvm was installed correctly by running $ command -v nvm.
4.a If the response is anything other than $ nvm, add the following two lines to the ~/.bash-profile file:
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
4.b Restart your computer (you can try closing Terminal and restarting it first)
4.c $ command -v nvm should now returnnvm`
Now update Node.js with $ nvm install --lts
Update npm: $ nvm install-latest-npm
$ npm install --global mocha. Finally, success! Well, for me and I hope for you too.
While the accepted answer does technically work, it's worth noting that Homebrew installation is not officially supported by the nvm package. The recommended way to avoid issues like those raised above is to apply either of the below methods of installation.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
# or wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
source: https://github.com/creationix/nvm
To install nvm, brew install nvm
To run nvm after installation or just once, $(brew --prefix nvm)/nvm.sh
To run nvm everytime zsh opens
nano ~/.zshrc
Add this line source $(brew --prefix nvm)/nvm.sh
The reason you would need to reload your bash profiles or any other bash files might be because the command nvm may not be a program but a function that is defined and can only be used if the corresponding bash file is sourced.
On a system that I checked
which nvm
does not work but
nvm list
does. This means that you can use the word "nvm" to invoke something. That something isn't a program. In the current case, it is a function which can be verified by
typeset -F | grep -P ' nvm$'
which outputs
declare -F nvm
which means nvm is a function, whose body can be inspected by doing
type -F nvm
One possibility if brew was used is that the nvm may be unlinked, especially if it was installed by another MAC OS user.
In this case, execute:
brew link nvm
I'd like to add that nvm's location on github changed and the version bumped.
The curl command now should be:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
if you happen to be using fish shell, consider https://github.com/jorgebucaran/nvm.fish
Instructions from
lukechilds/zsh-nvm#as-an-oh-my-zsh-custom-plugin
If you are using mac os + zsh + oh-my-zsh:
Clone zsh-nvm into your custom plugins repo
git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm
Then load nvm as a plugin in your .zshrc file
plugins+=(zsh-nvm)
Keep in mind that plugins need to be added before oh-my-zsh.sh is sourced.
f.e.
$ nano ~/.zshrc
// edit .zshrc contents
...
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# docs: f.e. https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/kubectl
plugins=(zsh-nvm)
source $ZSH/oh-my-zsh.sh
...
Finally reload the configuration $ source ~/.zshrc

SVN using wrong sqlite version

when running my svn from /usr/local/bin/ it says:
svn: E200029: Couldn't perform atomic initialization
svn: E200030: SQLite compiled for 3.7.13, but running with 3.6.12
sqlite3 --version gives me 3.7.13
What went wrong and how can I fix it?
I'm on Mac OS X (10.6.8).
//edit1:
/usr/local/bin/sqlite3 --version 3.7.13
/usr/bin/sqlite3 --version 3.7.13
//edit2: I "fixed" this by installing svn via homebrew and using /usr/local/bin/svn explicitly
Let me sum up the fixes and suggestion from the answers below:
(please upvote the corresponding answer)
For Mac users:
(re-)install svn via homebrew or whatever you use (you may need to brew link --force sqlite3)
For Fedora users:
try yum update sqlite3 or yum install sqlite
I experienced the same issue, I solved downloading http://www.sqlite.org/sqlite-amalgamation-3.7.6.3.tar.gz, unpacking the archive using tar/gunzip and coping sqlite3.c from the resulting directory into $svn-src-folder/sqlite-amalgamation/sqlite3.c.
Run configure/make/sudo make install and you should solve.
I had brew, svn 1.8, working fine in OSX 10.8.
I upgraded to 10.9, broke. For some reason the symlinks brew makes in /usr/local/bin were removed by the 10.9 installation?
brew update didnt fix.
brew install svn fixed svn, or so I thought.
Then actually using svn 1.8 (/usr/local/bin first in my path) I also had the above sqlite error message. A newer sqlite being in /usr/local/Cellar, but not symlinked in /usr/local/bin or anything.
brew install sqlite3 ... didnt fix it. And I noticed brew says for this component it doesnt symlink. ok.
BUT, after that reinstall, a further reinstall of svn
brew svn uninstall
brew svn install
DID fix it. dont know why. Now can svn co successfully.
After re-linking subversion, I had also to re-link sqlite3
brew link --force sqlite3
It means subversion was compiled with SQLite version 3.7.13, but now you are running SQLite 3.6.12.
All you need to do is recompile/reinstall your subversion again.
update sqlite3!!
I had similar issue on Fedora Core 20
Did the following:
yum update sqlite3
For me, yum install sqlite in fedora fixed the problem.

Resources