Warning: Found ~/.mongorc.js, but not ~/.mongoshrc.js. ~/.mongorc.js will not be loaded

Hi @William_Rutkowski, @Mariluz_de_la_Parra,

This warning message is ignorable. It happens when you have previously run the legacy mongo shell (which creates a .mongorc.js in your home directory) and subsequently run the new MongoDB Shell (mongosh) which looks for .mongoshrc.js instead.

The “rc” file naming convention comes from Unix, where it indicates “Run Commands” that are invoked when an application starts up. In the context of the MongoDB shell, the rc file can be used to load some additional JavaScript commands or helpers:

On startup, mongosh checks the user’s HOME directory for a JavaScript file named .mongoshrc.js . If this file is found, mongosh interprets the content of .mongoshrc.js before displaying the prompt for the first time.

The mongosh startup warning is trying to convey that a legacy .mongorc.js file was found but will not be loaded by mongosh. If you added any custom JavaScript in .mongorc.js, you may want to update and add those commands to .mongoshrc.js. This is suggested in the second line of the warning:

You may want to copy or rename ~/.mongorc.js to ~/.mongorcsh.js

You can inspect the contents of these JavaScript files in your favourite text editor.

Regards,
Stennie

9 Likes