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

4

8

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?

Olva answered 12/3, 2014 at 10:29 Comment(0)
H
2

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.

Hugh answered 12/3, 2014 at 10:46 Comment(0)
N
5

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

Nesline answered 2/4, 2016 at 18:12 Comment(0)
H
2

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.

Hugh answered 12/3, 2014 at 10:46 Comment(0)
J
0

I was getting the following error:

2017-10-02T12:54:21.435-0500 I STORAGE In File::open(), CreateFileW for 'H:\.mongorc.js' failed with errno:3 The system cannot find the path specified.

I created directories /data/db under the location I was getting the error and it resolved the issue.

H:\>md data

H:\>cd data

H:\data>md db

I was able to connect without any issue once those directories were created.

H:\data>mongo
MongoDB shell version: 3.0.15
connecting to: test
> db.names.insert({'name':'Mahrukh Khan'});
WriteResult({ "nInserted" : 1 })
>
Judijudicable answered 2/10, 2017 at 19:12 Comment(0)
B
0

You can simply delete .mongorc.js file using sudo rm .mongorc.js and the problem would be solved.

Boudoir answered 10/6, 2019 at 19:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.