[DOCS-5652] detail the mongo shell startup behaviour related to .mongorc.js Created: 17/Jun/15  Updated: 30/Oct/23  Resolved: 01/Nov/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: Anil Kumar Assignee: Kay Kim (Inactive)
Resolution: Won't Fix Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Participants:
Days since reply: 1 year, 14 weeks, 1 day ago
Epic Link: DOCSP-1769

 Description   

We should details the mongo shell startup behaviour around the creation of .mongorc.js under a defined directory that varies based on the platform.

If the .monogrc.js is not found under the specified path selected as per the below mentioned code path in src/mongo/shell/dbshell.cpp, the shell will try to create an empty file. This may fail because the path may not be environment variables may not be appropriately set. In case, this is not specified in the docs, the user will remain clueless on what should be set.

#ifndef _WIN32
            if ( getenv( "HOME" ) != NULL )
                rcLocation = str::stream() << getenv( "HOME" ) << "/.mongorc.js" ;
#else
            if ( getenv( "HOMEDRIVE" ) != NULL && getenv( "HOMEPATH" ) != NULL )
                rcLocation = str::stream() << toUtf8String(_wgetenv(L"HOMEDRIVE"))
                                           << toUtf8String(_wgetenv(L"HOMEPATH"))
                                           << "\\.mongorc.js";
#endif



 Comments   
Comment by Education Bot [ 01/Nov/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Comment by Ben Creasy [ 23/Jul/15 ]

Could we please also allow the location of .mongorc.js to be set to a custom location? Somehow, Linux (and some other Unix users) should be able to put this file in $XDG_CONFIG_HOME/mongodb/. This is a pretty commonly standard which cleans up the $HOME folder.

This seems like the right issue for this, but if not let me know and I can try to make another one.

See this Stack Overflow thread where the answerer says "will be a 'global; mongorc in future versions" and suggests a workaround. Also I will cross-reference this issue at XDG Directory Support.

Generated at Thu Feb 08 07:50:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.