unable to install mongodb. Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local) - mongodb

Can someone help me please. I keep trying to install mongodb using different methods but I can never get past a certain point.
I have homebrew installed, and it's updated. And x-code installed as well.
It's when I run % brew install mongodb-community#5.0 or % brew install mongodb-community#4.2 that I get this error message-
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
also, note: I have a Macbook Pro with an M1 Max chip
Thank you in advance for any help!

Related

Having trouble installing mongodb on macOS bigsur

Warning: No available formula with the name "mongosh" (dependency of mongodb/brew/mongodb-community). Did you mean mongocli?
==> Searching for similarly named formulae...
This similarly named formula was found:
mongocli
To install it, run:
brew install mongocli
It was migrated from mongodb/brew to homebrew/core.
this is what is says in the terminal after writing brew tap mongodb/brew . Im trying to us homebrew to install mongodb on macOS bigsur
To use MongoDB shell mongosh, you need to download it from here https://downloads.mongodb.com/compass/mongosh-1.2.2-darwin-x64.zip

cannot link libpq on Mac M1

I've been trying to run the Rust Diesel crate on my Macbook M1 and it doesn't work. The final part of the compilation gets broken by the following error:
= note: ld: warning: ignoring file /usr/local/Cellar/libpq/14.1/lib/libpq.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
When I get the info for libpq I get the following:
maxwellflitton#Maxwells-MacBook-Pro vanguard % brew info libpq
libpq: stable 14.1 (bottled) [keg-only]
Postgres C API library
https://www.postgresql.org/docs/14/libpq.html
/usr/local/Cellar/libpq/14.1 (2,335 files, 27.8MB)
Poured from bottle on 2022-01-09 at 00:14:32
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libpq.rb
License: PostgreSQL
==> Dependencies
Required: krb5 ✔, openssl#1.1 ✔
==> Caveats
libpq is keg-only, which means it was not symlinked into /usr/local,
because conflicts with postgres formula.
If you need to have libpq first in your PATH, run:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
For compilers to find libpq you may need to set:
export LDFLAGS="-L/usr/local/opt/libpq/lib"
export CPPFLAGS="-I/usr/local/opt/libpq/include"
I've tried installing with the following command:
RUSTFLAGS='-L /usr/local/Cellar/libpq/14.1/lib' cargo install diesel_cli --no-default-features --features postgres --force
But I still get the same error. Will it just be easier to wipe the whole thing and start again and if so how would I do this? Other people on the internet using the M1 seem to be able to get round the problem with a simple brew install libpq. Never had any issues with my previous intel mac. My ~/.cargo/config.toml has the following configuration:
[target.aarch64-apple-darwin]
rustflags = '-L /usr/local/Cellar/libpq/14.1/lib -L /opt/homebrew/lib'
Surprisingly this worked
brew install postgresql libpq
cargo clean
cargo build
cargo install diesel_cli --no-default-features --features postgres
I think it had to do with installing diesel-cli before installing the necessary dependencies. Cleaning the cargo dependencies and reinstalling worked for me
on my M1 mac, I installed the postgresql client and library with brew:
brew install postgresql libpq
and attempted to install diesel_cli again, this time it worked fine:
cargo install diesel_cli --no-default-features --features postgres
for some reason, simply installing libpq was not enough to install diesel_cli, i had to install the postgres library and the client.
Encountered a similar problem, and the issue was coming from my brew config (I restored my filesystem from my mac Intel) :
❯ brew config
...
macOS: 12.6-x86_64
...
Therefore, brew was downloading packages built for intel processors. I uninstalled and reinstalled brew following their website and now brew config is correct:
❯ brew config
...
macOS: 12.6-arm64
...
Hope this helps!
I have a Mac M1 and installed both postgresql and libpq with brew
I eventually succeeded in installing diesel_cli with these lines in my ~/.cargo/config.toml file
[target.aarch64-apple-darwin]
rustflags = '-L /opt/homebrew/opt/libpq/lib -L /opt/homebrew/lib'
source was https://github.com/diesel-rs/diesel/issues/2605

Installing mongodb on M1 mac

I tried opening the terminal using Rosetta but when I run brew install mongodb-community#5.0 I get an error that says:
Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)! To rerun under ARM use: arch -arm64 brew install ... To install under x86_64, install Homebrew into /usr/local.
However, when I run it as arch -arm64 brew install mongodb-community#5.0, it again complains with:
arch: posix_spawnp: brew: Bad CPU type in executable
Any help would be appreciated.
Thanks in advance.
There are two versions of brew:
Intel version (in /usr/local/homebrew)
ARM64 version for Apple Silicone (in /opt/homebrew/)
When you just type brew you are probably using native ARM64 version, for which there is no mongodb server yet.
You can check which version is your default with this:
$ which brew
/opt/homebrew/bin/brew
The solution I find most practical is to define alias for Intel brew like this in .zshrc:
# arm64/intel brew
alias brew86="arch -x86_64 /usr/local/Homebrew/bin/brew"
alias brewARM="/opt/homebrew/bin/brew"
# ARM64 brew is default
eval "$(/opt/homebrew/bin/brew shellenv)"
Then you can use intel brew to install intel based apps like this:
brew86 install mongodb-community
brew86 services
...
And you can use ARM64 brew to install native ARM64 stuff like this:
brew install mongosh
Important note - do not use "Open using rosetta2" to launch terminal window in which you gonna run these commands. You wish to be in native ARM64, then install Intel apps only when is absolutely needed with brew86.
For some reason even though I had Homebrew in /usr/local the one for M1 was being executed. Solved it by manually navigating in /usr/local/Homebrew/bin and running the commands with ./brew.

Mongodump/OpenSSL - "image not found" error

I recently updated macOS to Catalina and mongodump is no longer working. I've updated
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/opt/mongodb#3.6/bin/mongodump
Reason: image not found
I see a few questions out there such as this one: dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib. This is the accepted response:
brew update && brew upgrade
brew uninstall openssl
brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
However, I get this error when trying to install version 1.0.0:
Error: Calling Non-checksummed download of openssl formula file from an arbitrary URL is disabled! Use 'brew extract' or 'brew create' and 'brew tap-new' to create a formula file in a tap on GitHub instead.
Is there any way around this? I'm not really sure where to go from that message.
You can check which version of Homebrew is installed by running brew --version
You can use my previous response to implement how Homebrew now suggests it. Or if you want to use previous version of Homebrew to use these commands then follow this:
Go to Homebrew folder cd /usr/local/Homebrew/
Checkout to the previous version by running git checkout 2.3.0
To install OpenSSL HOMEBREW_NO_AUTO_UPDATE=1 brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
Source: https://github.com/kelaberetiv/TagUI/issues/635#issuecomment-699482920

unable to update to Ruby 2.1.4

Currently running Yosemite and unable to update to ruby 2.1.4 , see below.
Guidos-MacBook-Pro:~ Guido$ rvm install 2.1.4
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.10/x86_64/ruby-2.1.4.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx_brew.
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 26: /usr/local/Library/brew.rb: Undefined error: 0
ERROR: '/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.
So after I stepped away from the computer for a few hours and came back again, I figured out the issue was that Homebrew was broken after I updated OS to Yosemite. Here is the link http://ryantvenge.com/2014/09/ruby-homebrea-yosemite/ to the solution. If that is not working see commands below.
To fix Homebrew:
cd /System/Library/Frameworks/Ruby.framework/Versions
sudo ln -s Current 1.8
brew update
sudo rm 1.8
To update to ruby 2.1.4:
rvm install 2.1.4
rvm use 2.1.4