Failed: open /dataset/products.json: no such file or directory

Chapter 1: The Mongod
Lab - Importing a Dataset

i am trying to run this command
mongoimport --drop --port 27000 -u “m103-application-user”
-p “m103-application-pass” --authenticationDatabase “admin”
–db applicationData --collection products /dataset/products.json

output error
---------------
Failed: open /dataset/products.json: no such file or directory
** imported 0 documents**

Hi @Lifas_39126,

Please run the following command and share the output.

cd /dataset

ls

Note : Please refrain from posting answers to the lab in the discussion forum.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

vagrant@m103:~ cd /dataset vagrant@m103:/dataset ls
vagrant@m103:/dataset$

Hi @Lifas_39126,

Please run the following command in the specified order to download the datasets.

For products.json

curl -s https://s3.amazonaws.com/edu-static.mongodb.com/lessons/M103/products.json.tgz -o products.json.tgz

tar -xzvf products.json.tgz -C /dataset

rm -rf products.json.tgz

For products.part2.json

curl -s https://s3.amazonaws.com/edu-static.mongodb.com/lessons/M103/products.part2.json.tgz -o products.part2.json.tgz

tar -xzvf products.part2.json.tgz -C /dataset

rm -rf products.part2.json.tgz

Hope it helps!

Please feel free to get back to us if you still face any issue.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

vagrant@m103:/ curl -s https://s3.amazonaws.com/edu-static.mongodb.com/lessons/M103/products.json.tgz -o products.json.tgz vagrant@m103:/ tar -xzvf products.json.tgz -C /dataset
tar (child): products.json.tgz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
vagrant@m103:/$ rm -rf products.json.tgz

Hi @Lifas_39126,

Please change your current working directory to /home/vagrant and then run all the commands that I mentioned in post #4 .

For changing the directory you can run this command cd /home/vagrant or simply the cd command will work as well.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

vagrant@m103:~ cd /home/vagrant vagrant@m103:~ cd
vagrant@m103:~ curl -s https://s3.amazonaws.com/edu-static.mongodb.com/lessons/M103/products.json.tgz -o products.json.tgz vagrant@m103:~ tar -xzvf products.json.tgz -C /dataset
products.json
tar: products.json: Cannot open: Permission denied
tar: Exiting with failure status due to previous errors

Hi , Anyone one can help to fix this issue ???

Hi @Lifas_39126,

Share the output of these commands.

ls -lart /

ls -lart /dataset

Hi @Lifas_39126,

root is the owner of the /dataset directory. Please change it to vagrant by running the following command:

sudo chown vagrant:vagrant /dataset

This should resolve the issue.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

vagrant@m103:/$ sudo chown vagrant:vagrant /dataset

vagrant@m103:/ vagrant@m103:/ mongoimport --host localhost:27000 -u m103-application-user -p m103-application-pass -d applicationData /dataset/products.json
2019-12-30T10:47:12.428+0000 no collection specified
2019-12-30T10:47:12.429+0000 using filename ‘products’ as collection
2019-12-30T10:47:12.430+0000 Failed: open /dataset/products.json: no such file or directory
2019-12-30T10:47:12.431+0000 imported 0 documents
vagrant@m103:/$ mongoimport --host localhost:27000 -u m103-application-user -p m103-application-pass -d applicationData /dataset/products.json
2019-12-30T10:48:11.233+0000 no collection specified
2019-12-30T10:48:11.234+0000 using filename ‘products’ as collection
2019-12-30T10:48:11.235+0000 Failed: open /dataset/products.json: no such file or directory
2019-12-30T10:48:11.236+0000 imported 0 documents

Hi @Lifas_39126,

After changing the ownership, you are supposeed to run the commands that I have mentioned in post #4.

still the same error like before

vagrant@m103:/ curl -s https://s3.amazonaws.com/edu-static.mongodb.com/lessons/M103/products.json.tgz -o products.json.tgz vagrant@m103:/ tar -xzvf products.json.tgz -C /dataset
tar (child): products.json.tgz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
vagrant@m103:/ rm -rf products.json.tgz vagrant@m103:/

Hi @Lifas_39126,

You are doing the same mistake which I mentioned in post #6.

please correct if i am wrong ,my vagrant directory is in C:/users/user1/handouts/m103/m103-vagrant-env and i am running and provisioning vagrant in this directory. should i change this directoy , or simply need to run vagrant@m103:/$ cd /home/vagrant …

Just going to add that if all the vagrant directories /shared, /dataset and /vagrant are now owned by root (indicated by a previous post), then they are no longer being synced. The first time you run vagrant up, all three dirs are created and owned by vagrant so if the ownership has changed, then something has gone wrong… potentially after you rebooted your local machine.

The first thing to try would be a reload:
vagrant reload
vagrant ssh
ls -l /{shared,dataset}

If that doesn’t work, follow the steps in this post. Do this as an Admin user.

1 Like

Hi @007_jb,

Good catch. I missed it.

I would have missed it too. I only remembered because I worked through this with another poster recently.

hi when i am running the command

C:\Users\fascs\Handouts\m103\m103-vagrant-env>vagrant reload
==> mongod-m103: Attempting graceful shutdown of VM…
mongod-m103: Guest communication could not be established! This is usually because
mongod-m103: SSH is not running, the authentication information was changed,
mongod-m103: or some other networking issue. Vagrant will force halt, if
mongod-m103: capable.
==> mongod-m103: Forcing shutdown of VM…
==> mongod-m103: Clearing any previously set forwarded ports…
==> mongod-m103: Fixed port collision for 22 => 2222. Now on port 2200.
==> mongod-m103: Clearing any previously set network interfaces…
==> mongod-m103: Preparing network interfaces based on configuration…
mongod-m103: Adapter 1: nat
mongod-m103: Adapter 2: hostonly
==> mongod-m103: Forwarding ports…
mongod-m103: 22 (guest) => 2200 (host) (adapter 1)
==> mongod-m103: Running ‘pre-boot’ VM customizations…
==> mongod-m103: Booting VM…
==> mongod-m103: Waiting for machine to boot. This may take a few minutes…
mongod-m103: SSH address: 127.0.0.1:2200
mongod-m103: SSH username: vagrant
mongod-m103: SSH auth method: private key
mongod-m103: Warning: Remote connection disconnect. Retrying…
mongod-m103: Warning: Remote connection disconnect. Retrying…
mongod-m103: Warning: Remote connection disconnect. Retrying…

is this the cause of my issue?
and ,after this commands
vagrant reload
vagrant ssh
ls -l /
ls -l /dataset
ls -l /shared -such-file-or-directory/43007/4) .
here is the output of these commands
can i try the mongod import command or need to do the steps in post #4.