Importing a Dataset - How do I get the file in my Vagrant?


While executing the mongoimport command I’m getting the error as no such file or directory,

2019-12-21T09:31:16.704+0000 Failed: open /dataset/products.json: no such file or directory
2019-12-21T09:31:16.706+0000 imported 0 documents

Command: mongoimport --port 27000 --username “m103-application-user” --password “m103-application-pass” --db applicationData --collection products --authenticationDatabase admin --file /dataset/products.json

When I checked the dataset folder in my course drive the products.json is present. But when checked in linux its not showing the file,

vagrant@m103:/dataset$ ls -lrth
total 0

whats the reason ??


Let’s see a screenshot of this:
ls -l /



The /shared and /dataset directories have been disconnected and not synced to the vagrant VM hence the error accessing them. This probably happened after you rebooted your laptop/PC.

Try the following steps:

  1. Open VirtualBox
    – open the Settings for the m103 machine
    – open the settings for each synced folder and tick Auto-Mount and hit OK. Example below:

    NB: If the OK button is greyed out, browse to the folder again using Folder Path and it will become active
  2. Come out of the VM
    – run vagrant halt
    – run vagrant reload or vagrant up
    – log back in (vagrant ssh) and check ls -l / again. If it’s owned by vagrant:vagrant, then it’s resynced.

Let me know the outcome.

PS: It might be similar to the problem you’re having in your other thread.

1 Like

Thanks 007_jb.

But I am not able to save it. The OK button is greyed out.

Ok, I’ll edit some parts of the post.

Using Folder Path, browse to the folder again and it will become active.

I did the changes but still the ownership is not changed to vagrant.

Its the same as shared earlier.

And if you run ls -l /dataset there’s still nothing showing up?
In step 2, did you try up instead of reload?
And in the folder settings on VirtualBox, is Make Permanent ticked?

Here’s another more promising set of steps:

  1. On your local machine, take a copy of the Vagrantfile
  2. Open the original Vagrantfile in a text editor (i.e. Notepad++, etc)
  3. Replace these lines:
    config.vm.synced_folder "shared/", "/shared", create: true
    config.vm.synced_folder "dataset/", "/dataset", create: true
    With these lines:
    config.vm.synced_folder "shared/", "/shared", create: true, disabled: true, owner: "vagrant", group: "vagrant"
    config.vm.synced_folder "dataset/", "/dataset", create: true, disabled: true, owner: "vagrant", group: "vagrant"
  4. Save the file. *** Don’t do ‘Save As’, just Save.
  5. Reload vagrant:
    vagrant reload
  6. Open the Vagrantfile again and on the lines you added from step 3, change disabled: true to disabled: false
  7. Save the file
  8. Run the following commands:
    vagrant reload
    vagrant ssh
    ls -l /
    ls -l /dataset
    ls -l /shared

NB: Try not to miss a step because it won’t work if you do.

Let me know how it goes. I have other options for you if this one doesn’t work.

Thanks for your help but that doesn’t work either, as not having permission to edit the vagrant file.

Permissions cannot be edited for system users having read/write privileges on course path.

@Sonali_Mamgain please help me. I am very short of time and not able to do anything.

I don’t understand what exactly you’re referring to because the Vagrant file is on your local machine. Can you share a screenshot to explain.

Yes I know, but I am not able to save the new settings in vagrant file. Permissions are not there.

And when I gave the administrator permission, it not allowing.


That’s strange! And you downloaded this file from the current course?

Choose one of these options:

  1. Option 1: To have full permissions to Vagrantfile and resync folders. Do this only if you don’t have Admin rights to your machine.
    – Rename Vagrantfile to Vagrantfile_original. If you cannot rename the file, move it to a different location.
    – Open Vagrantfile_original
    – Do a File > Save As > in File Name enter Vagrantfile > in Save as Type select All Types (*.*) and hit Save
    – Now you should have a Vagrantfile with full permissions
    – Start with the steps from my post #9
  2. Option 2: To recreate the synced folders without losing anything
    – Take a copy of the shared and dataset folders on your local machine
    – SSH into the box
    – Use sudo to delete the /dataset and /shared folders:
    sudo rm -r /{dataset,shared}
    sudo rm -r /dataset
    sudo rm -r /shared
    – Run step 8 in my post #9
  3. Option 3: Start from scratch… Note, this will completely reset the m103 VM
    – Destroy the box and bring it back up
    vagrant destroy
    vagrant up

Let me know.

Now when I did the changes in my vagrant file, I am not able to SSH in my VM

`initialize’: Permission denied @ rb_sysopen - E:/Course/m103/m103-vagrant-env/.vagrant/machines/mongod-m103/virtualbox/box_meta (Errno::EACCES)

What is this error? Are you sure that doing changes to Vagrant file doesn’t affect anything ??

Which option did you choose?
And show me a screenshot of the full error message.

Go to this location and check the permissions of this file.

Its the same, what we usually have. I didn’t do any changes in this location.

You forgot to respond to these two questions

I just downloaded the Vagrant file from the current session and I have full permissions. Why do you have read/write permissions only? Did someone else download and install this course for you?

Hi 007_jb,

I used the first option.

Yes I downloaded the file from the current course itself. No one did downloaded for me.

I did every homework and it was all running fine. But now after I did the changes in vagrant file, not able to start the vagrant up.

I rollback the changes with the copy of vagrant file to make as it is, still not working now.

Really pissed off !!!

Let’s see a screenshot of the error message in full.

And do you have Admin access to your machine?

How did you do this? Please explain.

I took the backup of original vagrant file at different location before making the changes. Then I simply replaced it with the backup copy file.

Error is the only one I posted above…rest its all binaries like below,