Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The `.mongorc.js` is not found, but there is one

When I start the mongo client mongo.exe, it prints out the following error:

MongoDB shell version: 2.4.9
connecting to: test
Wed Mar 12 11:15:47.013 In File::open(), CreateFileW for 'C:\Users\Zolt�n\.mongo
rc.js' failed with errno:3 The system cannot find the path specified.
Wed Mar 12 11:15:47.014 In File::len(), GetFileSizeEx for 'C:\Users\Zolt�n\.mong
orc.js' failed with errno:6 The handle is invalid.
Wed Mar 12 11:15:47.015 In File::read(), SetFilePointerEx for 'C:\Users\Zolt�n\.
mongorc.js' tried to set the file pointer to 0 but failed with errno:6 The handl
e is invalid.
>

As you see, my user path is C:\User\Zoltán and the character á is read as an unknown character. I bet this is the problem, why mongo can't find my .mongorc.js.

Is there any way I can explicitly set the path for .mongorc.js. Maybe with a configuration file?

like image 499
Dyin Avatar asked Mar 12 '14 10:03

Dyin


2 Answers

mongo --norc ignores the file, and you're good to go.

like image 173
Keon Avatar answered Oct 07 '22 17:10

Keon


Not yet there isn't. There will be a "global" mongorc in future versions. For now you can "fake it" like so:

mongo --norc --shell fake.js

So you tell the shell to ignore looking for .mongorc.js then you pass in a javascript file just like you would if you wanted to run the contents.

The --shell parameter forces the return to "shell" after the file ("fake.js") has been evaluated.

So just put any valid JavaScript in that file and it will be treated like the entries in the standard .mongorc.js.

like image 34
Neil Lunn Avatar answered Oct 07 '22 16:10

Neil Lunn