Error Installing on M1 Macbook

I followed these steps to install MongoDB:

When I start running MongoDB, no error pops up. It just says " ==> Successfully started mongodb-community (label: homebrew.mxcl.mongodb-commu"

But when I check the status, I get a 19968 error:

Also, when I check mongo --version, I get this error: “zsh: bad CPU type in executable: mongo”

I checked the var/log/mongodb/output.log but that is an empty file.

Can anyone help me fix these errors?

1 Like

What command line did you use to start mongod?

I used “brew services start mongodb-community@5.0”

Have you tried the manual start mongod --config /opt/homebrew/etc/mongod.conf --fork
If so, what was the result?

Also, check ps -ef | grep mongo to see if maybe you have some piece of mongo stuck and running despite the error messages.

When I try to manual start mongod, I get this error: “zsh: bad CPU type in executable: mongod”
and when I check “ps -ef | grep mongo”, it says this: “501 43048 42112 0 11:12PM ttys000 0:00.00 grep mongo”

zsh: bad CPU type in executable: mongod

You’ve somehow installed the wrong executable, it seems.

501 43048 42112 0 11:12PM ttys000 0:00.00 grep mongo

That’s the grep process itself searching for the string mongo … it finds itself.

Do you have any suggestions on what I should do next? Thanks

@SM_A maybe you can try this:

  1. Use brew to uninstall.
  2. Update/refresh brew … make entirely sure brew itself is installed correctly for an M1.
  3. Carefully try again to install following the directions and paying special attention to the prerequisites.

If it still doesn’t work, submit a bug report. The Forums here are more and more “community supporting community” and you’ll have better chances of getting serious attention with a well-formatted bug report if there really is a problem.

I feel for you :slight_smile: I have a Mac, but not an M1, so I can’t try this myself.

Hmm, searching I find some stuff about using Rosetta during the install.
See this Stack Exchange question @SM_A … it’s long but it may be the answer.

Hi @SM_A,

You will need Rosetta2 emulation installed (a one-off procedure) to run MongoDB 5.0 on M1. NOTE: native M1 binaries are coming with MongoDB 6.0.

However, I expect macOS should automatically prompt you to install Rosetta rather than complaining about a bad CPU type.

Can you confirm the output of:

file $(which mongod)

sw_vers

On my M1 with a brew install of MongoDB 5.0 the file command returns:

/opt/homebrew/bin/mongod: Mach-O 64-bit executable x86_64

You could try manually installing Rosetta 2:

softwareupdate --install-rosetta

Regards,
Stennie

Thanks @Stennie_X
I installed Rosetta. When checking mongo --version now, it looks correct. But when I check the status after running Mongo, it still shows an error:


What should I do now? Thank you.

I also tried reinstalling mongoDB in a rosetta clone terminal, but this error pops up:

Check your mongod.log
use brew --prefix to find your var/log location
Most likely it is failing due to permissions issues on /tmp .sock .lock files

@Ramachandra_Tummala
I see two logs in my /var/log/mongodb folder:

  1. mongo.log - When I open, it says unable to read the file.
  2. output.log:

{“t”:{"$date":“2022-06-15T12:55:58.842Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:36:36.829Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:37:26.315Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:39:10.033Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:45:00.497Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:45:55.112Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T13:57:58.049Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T14:47:17.978Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}
{“t”:{"$date":“2022-06-15T15:00:03.140Z”},“s”:“F”, “c”:“CONTROL”, “id”:20574, “ctx”:"-",“msg”:“Error during global initialization”,“attr”:{“error”:{“code”:38,“codeName”:“FileNotOpen”,“errmsg”:“Can’t initialize rotatable log file :: caused by :: Failed to open /opt/homebrew/var/log/mongodb/mongo.log”}}}

Not sure what to do with this

It is unable to create the logfile
Check the permissions on /opt/homebrew/var/log/mongodb
Your mongod should be able to write to this dir
Also the dbpath directory

@Ramachandra_Tummala
I changed the permissions to this:
Screen Shot 2022-06-15 at 11.23.43 AM

But I am still getting the same mongo.log errors and installation errors

Does this directory exist?
Please show contents
Do you have any mongod.log already in that dir with different ownership/permissions

@Ramachandra_Tummala

I do not have a mongod.log. These are the logs I see:

I meant mongo.log only.On other os it is named as mongod.log
So why you are not able to open/read this file?
Can you show file permissions from terminal prompt instead of explorer view
ls -lrt mongod.log