Skip to content
Phil Myers edited this page Jan 24, 2016 · 15 revisions

Frequently Asked Questions (FAQs) - Course 3 Module 1

If you have have a general question that is not specific to the Module 1 content, it may have already been answered here.

Table of Contents

Q: The data directory not found or permission denied

A: Create the data directory C:\data\db (windows) or /data/db (linux)

In windows:

C:\>mkdir -p C:\data\db

In Linx or Mac, as root user:

$ mkdir -p /data/db
$ chown -R mongod:mongod /data/db

Otherwise:

$ sudo mkdir -p /data/db
$ sudo chown -R mongod:mongod /data/db

See also:

Back To Top

Q: WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

After installing and running the mongo server,

$ mongod

Then in a another terminal, when running the mongo client,

$ mongo

The following warnings are shown:

Server has startup warnings:

2016-01-19T20:59:55.320-0800 I CONTROL [initandlisten]

2016-01-19T20:59:55.320-0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

What to do?

A: In Linux, set the resource limit just before starting mongod with this:

$ ulimit -n 1024
$ mongod

Back To Top

Q: mongod waiting for connections on port 27017

After doing mongod it shows:

[initandlisten] waiting for connections on port 27017

In the video a connection was accepted, that line is missing on my computer. Is this a problem?

A: No, this is not a problem. That was probably because a client running was already running in the video.

When you start clean, mongod should just come and wait for connections. This is the MongoDB database server.

When you start mongo then you should see the connection accepted message since this is the client connecting to the database server.

Back To Top

Q: Error connecting to db server: no reachable servers

This error shows up when try to run mongoimport:

mongoimport --db test --collection zips --drop --file zips.json

A: This happens if MongoDB Server (mongod) is not running. In a different terminal, go ahead and start mongod and then do an import.

Back To Top

Q: NameError: uninitialized constant Mongo::Client

In irb,

rb(main):001:0> require 'mongo'
=> true
irb(main):002:0> db = Mongo::Client.new('mongodb://localhost:27017')
NameError: uninitialized constant Mongo::Client
    from (irb):2
    ...

A: This error is because the `mongo`` ruby driver was not loaded properly.

First in the command shell ensure that you have installed the ruby gems by running:

C:\>gem install mongo
C:\>gem install bson_ext

Now start irb and run the command:

C:\>irb

irb(main):001:0> require 'mongo'
=> true

irb(main):004:0> db = Mongo::Client.new('mongodb://localhost:27017')
D, [2016-01-23T09:33:16.963650 #4156] DEBUG -- : MONGODB | Adding localhost:27017 to the cluster.
=> #<Mongo::Client:0x24416640 cluster=localhost:27017>

Back To Top

Q: Hash Rocket Notation vs. JSON Notation

Is there any particular reason for choosing to use the :symbol => "value"`` (Hash Rocket) notation or symbol: "value"` (JSON) notation?

A: The GitHub Ruby style guide suggests just to use the hash-rocket syntax for Hash literals and Rails style guide prefers JSON.

So it really comes down to your preference and in which side of the fence you are on.

See also:

Q: Submission is failing because of directory structure

I'm seeing the error:

Application not found in root directory of archive. This may be an invalid archive format or application scoped below an extra directory.

How can I fix this?

A: You need to fix the directory structure of your submission. The Gemfile, the app directory, etc. need to be in the root of your zip, not in a folder. Let's say your app, Gemfile, etc. are in the my_project directory. You can ensure your zip is structured correctly, you can run the following commands:

cd my_project
zip -r my_project.zip .

In plain English, the zip command means zip the contents of my current directory (i.e. the .) recursively (the -r) and name it my_project.zip.

Back To Top

Clone this wiki locally