How to sync Python source files in a Vagrant box?












0















I'm using a local VM with a Vagrantfile similar to the following:



Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.define "dev", primary: true do |dev|
dev.vm.box = "venmo/platform-development"
dev.vm.box_version = '<= 2.17.2'
dev.vm.network "private_network", ip: "192.168.33.11"

dev.vm.provision "install_python_requirements", type: "shell",
inline: "/app/venmo_platform/current/script/install_python_requirements.sh",
privileged: false

dev.vm.synced_folder "/Users/kupeek/dev/vm-site-packages", "/app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages"

end
end
end


where the install_python_requirements.sh file is



#!/usr/bin/env bash

REQUIREMENTS_FILE='/app/venmo_platform/current/requirements.txt'

export ADD_GHE_KEYS=false
/app/venmo_platform/current/script/install_python_requirements.sh "${REQUIREMENTS_FILE}"

if [[ "${DEPLOYMENT_GROUP_NAME}" == *-test-user-management-api-platform-group ]]; then
CLEAR_DIR='/app/shared/virtualenvs/venmo_platform27/build'
DEV_REQUIREMENTS_FILE='/app/venmo_platform/current/dev_requirements.txt'

# need to clear out the build dir to prevent conflicts with previous installations
sudo rm -rf "${CLEAR_DIR}"
sudo mkdir "${CLEAR_DIR}"
sudo chown ubuntu:ubuntu "${CLEAR_DIR}"
sudo chmod 777 "${CLEAR_DIR}"

# install dev dependencies so that test user management API can import venmo_tests/factories.py
"${PIP}" install -r "${DEV_REQUIREMENTS_FILE}"
fi


When running Python tests in the VM, I occasionally run into errors like this:



   Traceback (most recent call last):
/app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 1305 in patched
return func(*args, **keywargs)
venmo_tests/communication/services/test_notification_service.py line 53 in test_custom_push_message
send_push_to_user_mock.assert_called()
/app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 906 in assert_called
raise AssertionError(msg)
AssertionError: Expected 'send_push_to_user' to have been called.


This error is being raised by pip-installed packages located in /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages, hence I would like to sync this to my local environment so that the virtualenv gets copied over and I can set a trace in it to debug the problem, similar to what I'm used to doing with 'ordinary' virtualenvs.



The problem is that this directory is not getting synced, it is empty:



LM-SJN-21018636:vm-site-packages kupeek$ pwd
/Users/kupeek/dev/vm-site-packages
LM-SJN-21018636:vm-site-packages kupeek$ ls
LM-SJN-21018636:vm-site-packages kupeek$


Am I not following the docs (https://www.vagrantup.com/docs/synced-folders/basic_usage.html) properly? (I've run vagrant reload after attempting to add the synced folder).










share|improve this question



























    0















    I'm using a local VM with a Vagrantfile similar to the following:



    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    config.vm.define "dev", primary: true do |dev|
    dev.vm.box = "venmo/platform-development"
    dev.vm.box_version = '<= 2.17.2'
    dev.vm.network "private_network", ip: "192.168.33.11"

    dev.vm.provision "install_python_requirements", type: "shell",
    inline: "/app/venmo_platform/current/script/install_python_requirements.sh",
    privileged: false

    dev.vm.synced_folder "/Users/kupeek/dev/vm-site-packages", "/app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages"

    end
    end
    end


    where the install_python_requirements.sh file is



    #!/usr/bin/env bash

    REQUIREMENTS_FILE='/app/venmo_platform/current/requirements.txt'

    export ADD_GHE_KEYS=false
    /app/venmo_platform/current/script/install_python_requirements.sh "${REQUIREMENTS_FILE}"

    if [[ "${DEPLOYMENT_GROUP_NAME}" == *-test-user-management-api-platform-group ]]; then
    CLEAR_DIR='/app/shared/virtualenvs/venmo_platform27/build'
    DEV_REQUIREMENTS_FILE='/app/venmo_platform/current/dev_requirements.txt'

    # need to clear out the build dir to prevent conflicts with previous installations
    sudo rm -rf "${CLEAR_DIR}"
    sudo mkdir "${CLEAR_DIR}"
    sudo chown ubuntu:ubuntu "${CLEAR_DIR}"
    sudo chmod 777 "${CLEAR_DIR}"

    # install dev dependencies so that test user management API can import venmo_tests/factories.py
    "${PIP}" install -r "${DEV_REQUIREMENTS_FILE}"
    fi


    When running Python tests in the VM, I occasionally run into errors like this:



       Traceback (most recent call last):
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 1305 in patched
    return func(*args, **keywargs)
    venmo_tests/communication/services/test_notification_service.py line 53 in test_custom_push_message
    send_push_to_user_mock.assert_called()
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 906 in assert_called
    raise AssertionError(msg)
    AssertionError: Expected 'send_push_to_user' to have been called.


    This error is being raised by pip-installed packages located in /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages, hence I would like to sync this to my local environment so that the virtualenv gets copied over and I can set a trace in it to debug the problem, similar to what I'm used to doing with 'ordinary' virtualenvs.



    The problem is that this directory is not getting synced, it is empty:



    LM-SJN-21018636:vm-site-packages kupeek$ pwd
    /Users/kupeek/dev/vm-site-packages
    LM-SJN-21018636:vm-site-packages kupeek$ ls
    LM-SJN-21018636:vm-site-packages kupeek$


    Am I not following the docs (https://www.vagrantup.com/docs/synced-folders/basic_usage.html) properly? (I've run vagrant reload after attempting to add the synced folder).










    share|improve this question

























      0












      0








      0








      I'm using a local VM with a Vagrantfile similar to the following:



      Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

      config.vm.define "dev", primary: true do |dev|
      dev.vm.box = "venmo/platform-development"
      dev.vm.box_version = '<= 2.17.2'
      dev.vm.network "private_network", ip: "192.168.33.11"

      dev.vm.provision "install_python_requirements", type: "shell",
      inline: "/app/venmo_platform/current/script/install_python_requirements.sh",
      privileged: false

      dev.vm.synced_folder "/Users/kupeek/dev/vm-site-packages", "/app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages"

      end
      end
      end


      where the install_python_requirements.sh file is



      #!/usr/bin/env bash

      REQUIREMENTS_FILE='/app/venmo_platform/current/requirements.txt'

      export ADD_GHE_KEYS=false
      /app/venmo_platform/current/script/install_python_requirements.sh "${REQUIREMENTS_FILE}"

      if [[ "${DEPLOYMENT_GROUP_NAME}" == *-test-user-management-api-platform-group ]]; then
      CLEAR_DIR='/app/shared/virtualenvs/venmo_platform27/build'
      DEV_REQUIREMENTS_FILE='/app/venmo_platform/current/dev_requirements.txt'

      # need to clear out the build dir to prevent conflicts with previous installations
      sudo rm -rf "${CLEAR_DIR}"
      sudo mkdir "${CLEAR_DIR}"
      sudo chown ubuntu:ubuntu "${CLEAR_DIR}"
      sudo chmod 777 "${CLEAR_DIR}"

      # install dev dependencies so that test user management API can import venmo_tests/factories.py
      "${PIP}" install -r "${DEV_REQUIREMENTS_FILE}"
      fi


      When running Python tests in the VM, I occasionally run into errors like this:



         Traceback (most recent call last):
      /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 1305 in patched
      return func(*args, **keywargs)
      venmo_tests/communication/services/test_notification_service.py line 53 in test_custom_push_message
      send_push_to_user_mock.assert_called()
      /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 906 in assert_called
      raise AssertionError(msg)
      AssertionError: Expected 'send_push_to_user' to have been called.


      This error is being raised by pip-installed packages located in /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages, hence I would like to sync this to my local environment so that the virtualenv gets copied over and I can set a trace in it to debug the problem, similar to what I'm used to doing with 'ordinary' virtualenvs.



      The problem is that this directory is not getting synced, it is empty:



      LM-SJN-21018636:vm-site-packages kupeek$ pwd
      /Users/kupeek/dev/vm-site-packages
      LM-SJN-21018636:vm-site-packages kupeek$ ls
      LM-SJN-21018636:vm-site-packages kupeek$


      Am I not following the docs (https://www.vagrantup.com/docs/synced-folders/basic_usage.html) properly? (I've run vagrant reload after attempting to add the synced folder).










      share|improve this question














      I'm using a local VM with a Vagrantfile similar to the following:



      Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

      config.vm.define "dev", primary: true do |dev|
      dev.vm.box = "venmo/platform-development"
      dev.vm.box_version = '<= 2.17.2'
      dev.vm.network "private_network", ip: "192.168.33.11"

      dev.vm.provision "install_python_requirements", type: "shell",
      inline: "/app/venmo_platform/current/script/install_python_requirements.sh",
      privileged: false

      dev.vm.synced_folder "/Users/kupeek/dev/vm-site-packages", "/app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages"

      end
      end
      end


      where the install_python_requirements.sh file is



      #!/usr/bin/env bash

      REQUIREMENTS_FILE='/app/venmo_platform/current/requirements.txt'

      export ADD_GHE_KEYS=false
      /app/venmo_platform/current/script/install_python_requirements.sh "${REQUIREMENTS_FILE}"

      if [[ "${DEPLOYMENT_GROUP_NAME}" == *-test-user-management-api-platform-group ]]; then
      CLEAR_DIR='/app/shared/virtualenvs/venmo_platform27/build'
      DEV_REQUIREMENTS_FILE='/app/venmo_platform/current/dev_requirements.txt'

      # need to clear out the build dir to prevent conflicts with previous installations
      sudo rm -rf "${CLEAR_DIR}"
      sudo mkdir "${CLEAR_DIR}"
      sudo chown ubuntu:ubuntu "${CLEAR_DIR}"
      sudo chmod 777 "${CLEAR_DIR}"

      # install dev dependencies so that test user management API can import venmo_tests/factories.py
      "${PIP}" install -r "${DEV_REQUIREMENTS_FILE}"
      fi


      When running Python tests in the VM, I occasionally run into errors like this:



         Traceback (most recent call last):
      /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 1305 in patched
      return func(*args, **keywargs)
      venmo_tests/communication/services/test_notification_service.py line 53 in test_custom_push_message
      send_push_to_user_mock.assert_called()
      /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/mock/mock.py line 906 in assert_called
      raise AssertionError(msg)
      AssertionError: Expected 'send_push_to_user' to have been called.


      This error is being raised by pip-installed packages located in /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages, hence I would like to sync this to my local environment so that the virtualenv gets copied over and I can set a trace in it to debug the problem, similar to what I'm used to doing with 'ordinary' virtualenvs.



      The problem is that this directory is not getting synced, it is empty:



      LM-SJN-21018636:vm-site-packages kupeek$ pwd
      /Users/kupeek/dev/vm-site-packages
      LM-SJN-21018636:vm-site-packages kupeek$ ls
      LM-SJN-21018636:vm-site-packages kupeek$


      Am I not following the docs (https://www.vagrantup.com/docs/synced-folders/basic_usage.html) properly? (I've run vagrant reload after attempting to add the synced folder).







      python vagrant






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 22:40









      Kurt PeekKurt Peek

      9,5751969141




      9,5751969141
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You can use NFS to sync folders. The following example will sync the local directory where your Vagrantfile is with the /vagrant directory in your VM:



          config.vm.synced_folder '.', '/vagrant', nfs: true


          Your machine must have nfsd installed as a prerequisite.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346347%2fhow-to-sync-python-source-files-in-a-vagrant-box%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You can use NFS to sync folders. The following example will sync the local directory where your Vagrantfile is with the /vagrant directory in your VM:



            config.vm.synced_folder '.', '/vagrant', nfs: true


            Your machine must have nfsd installed as a prerequisite.






            share|improve this answer




























              1














              You can use NFS to sync folders. The following example will sync the local directory where your Vagrantfile is with the /vagrant directory in your VM:



              config.vm.synced_folder '.', '/vagrant', nfs: true


              Your machine must have nfsd installed as a prerequisite.






              share|improve this answer


























                1












                1








                1







                You can use NFS to sync folders. The following example will sync the local directory where your Vagrantfile is with the /vagrant directory in your VM:



                config.vm.synced_folder '.', '/vagrant', nfs: true


                Your machine must have nfsd installed as a prerequisite.






                share|improve this answer













                You can use NFS to sync folders. The following example will sync the local directory where your Vagrantfile is with the /vagrant directory in your VM:



                config.vm.synced_folder '.', '/vagrant', nfs: true


                Your machine must have nfsd installed as a prerequisite.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 17 '18 at 0:09









                Aurora WangAurora Wang

                715216




                715216






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346347%2fhow-to-sync-python-source-files-in-a-vagrant-box%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to pass form data using jquery Ajax to insert data in database?

                    National Museum of Racing and Hall of Fame

                    Guess what letter conforming each word