hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

Quite frequently git does not work #7972

Closed bitliner closed 7 years ago

bitliner commented 7 years ago

Vagrant version

Vagrant 1.8.6

Host operating system

Mac OS Sierra

Guest operating system

puppetlabs/ubuntu-16.04-64-puppet

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  #config.vm.box = "ubuntu/trusty64"
  #config.vm.box = "bento/ubuntu-16.04"
  #config.vm.box = "geerlingguy/ubuntu1604"
  #config.vm.box = "boxcutter/ubuntu1604"
  #config.vm.box = "puphpet/ubuntu1604-x64"
  config.vm.box = "puppetlabs/ubuntu-16.04-64-puppet"

  ### PROVISION
  config.vm.provision "bootstrap_root", type: "shell", path: "./script/bootstrap_root_user.sh"
  config.vm.provision "docker", type: "shell", path: "./script/install_docker.sh"
  config.vm.provision "bootstrap_user",type:"shell", path: "./script/bootstrap_vagrant_user.sh", privileged:false
  config.vm.provision "startup", type: "shell",  path: "./script/startup.sh", run: "always"
  config.vm.provision "set_bashrc", type: "shell",  path: "./script/set_bashrc.sh", privileged:false
#  config.vm.provision "tools", type: "shell",  path: "./script/install_dev_tools.sh", privileged:false
  config.ssh.private_key_path=  [File.expand_path("~/.ssh/vagrant-1",__FILE__), '~/.vagrant.d/insecure_private_key','~/.ssh/id_rsa']
  config.ssh.forward_agent=true
  config.ssh.insert_key = false
  #config.ssh.forward_x11 = true

  # The url from where the 'config.vm.box' box will be fetched if it
  # doesn't already exist on the user's system.
  # config.vm.box_url = "http://domain.com/path/to/above.box"

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  ...some port ...

  # to try ranch server
  config.vm.network "forwarded_port", guest: 500, host: 500, protocol: "udp"
  config.vm.network "forwarded_port", guest: 4500, host: 4500, protocol: "udp"

  ### SPEED UP WORKING DIRECTORY
  # Required for NFS to work, pick any local IP

  #config.vm.network :private_network, ip: '192.168.50.50'
  # Use NFS for shared folders for better performance
#  config.vm.synced_folder '.', '/vagrant', nfs: true, mount_options: ['vers=3'], nfs_udp: false, nfs_version: 4
#  config.vm.synced_folder '.', '/vagrant', nfs: true, mount_options: ['vers=3']
#  config.vm.synced_folder '.', '/vagrant', nfs: true

  ### end SPEED UP WORKING DIRECTORY

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network :private_network, ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network :public_network
  # config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: "1.1.1.1"

  # If true, then any SSH connections made will enable agent forwarding.
  # Default value: false
  # config.ssh.forward_agent = true

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  #config.vm.provider :virtualbox do |vb|
  #   # Don't boot with headless mode
  #   vb.gui = true
  #
  #   # Use VBoxManage to customize the VM. For example to change memory:
  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
  #end
  #
  # View the documentation for the provider you're using for more
  # information on available options.
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    vb.customize ["modifyvm", :id, "--memory", "1024"]
  # vb.customize ["modifyvm", :id, "--cpus", cpus]
  end

  # Enable provisioning with Puppet stand alone.  Puppet manifests
  # are contained in a directory path relative to this Vagrantfile.
  # You will need to create the manifests directory and a manifest in
  # the file ubuntu/trusty64.pp in the manifests_path directory.
  #
  # An example Puppet manifest to provision the message of the day:
  #
  # # group { "puppet":
  # #   ensure => "present",
  # # }
  # #
  # # File { owner => 0, group => 0, mode => 0644 }
  # #
  # # file { '/etc/motd':
  # #   content => "Welcome to your Vagrant-built virtual machine!
  # #               Managed by Puppet.\n"
  # # }
  #
  # config.vm.provision :puppet do |puppet|
  #   puppet.manifests_path = "manifests"
  #   puppet.manifest_file  = "site.pp"
  # end

  # Enable provisioning with chef solo, specifying a cookbooks path, roles
  # path, and data_bags path (all relative to this Vagrantfile), and adding
  # some recipes and/or roles.
  #
  # config.vm.provision :chef_solo do |chef|
  #   chef.cookbooks_path = "../my-recipes/cookbooks"
  #   chef.roles_path = "../my-recipes/roles"
  #   chef.data_bags_path = "../my-recipes/data_bags"
  #   chef.add_recipe "mysql"
  #   chef.add_role "web"
  #
  #   # You may also specify custom JSON attributes:
  #   chef.json = { :mysql_password => "foo" }
  # end

  # Enable provisioning with chef server, specifying the chef server URL,
  # and the path to the validation key (relative to this Vagrantfile).
  #
  # The Opscode Platform uses HTTPS. Substitute your organization for
  # ORGNAME in the URL and validation key.
  #
  # If you have your own Chef Server, use the appropriate URL, which may be
  # HTTP instead of HTTPS depending on your configuration. Also change the
  # validation key to validation.pem.
  #
  # config.vm.provision :chef_client do |chef|
  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
  #   chef.validation_key_path = "ORGNAME-validator.pem"
  # end
  #
  # If you're using the Opscode platform, your validator client is
  # ORGNAME-validator, replacing ORGNAME with your organization name.
  #
  # If you have your own Chef Server, the default validation client name is
  # chef-validator, unless you changed the configuration.
  #
  #   chef.validation_client_name = "ORGNAME-validator"
  config.vm.provider "virtualbox" do |v|
    host = RbConfig::CONFIG['host_os']

    # Give VM 1/4 system memory & access to all cpu cores on the host
    if host =~ /darwin/
      cpus = `sysctl -n hw.ncpu`.to_i
      # sysctl returns Bytes and we need to convert to MB
      mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
    elsif host =~ /linux/
      cpus = `nproc`.to_i
      # meminfo shows KB and we need to convert to MB
      mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
    else # sorry Windows folks, I can't help you
      cpus = 2
      mem = 1024
    end
    mem=1024*6

    v.customize ["modifyvm", :id, "--memory", mem]
    v.customize ["modifyvm", :id, "--cpus", cpus]
  end
end

Please note, if you are using Homestead or a different Vagrantfile format, we may be unable to assist with your issue. Try to reproduce the issue using a vanilla Vagrantfile first.

Debug output

Provide a link to a GitHub Gist containing the complete debug output: https://www.vagrantup.com/docs/other/debugging.html. The debug output should be very long. Do NOT paste the debug output in the issue, just paste the link to the Gist.

Expected behavior

git working fine

Actual behavior

Quite often, if I run git commit the result is

error: bad index file sha1 signature
fatal: index file corrupt

Sometimes, when I run git add, the result is

error: insufficient permission for adding an object to repository database .git/objects
error: dist/index.html: failed to insert into database
error: unable to index file dist/index.html
fatal: updating files failed
chrisroberts commented 7 years ago

Hi. There isn't much here to be able to reproduce this error. I had a few runs using the virtualbox provider and was unable to reproduce. If you can provide a simple Vagrantfile that can reliably reproduce the error you are encountering, please open up a new issue. Thanks!

laurencei commented 7 years ago

@chrisroberts - I have a similar issue.

Vagrant 1.9.0 - on WIndows 10. Running Homestead box v1.0.1 "wmware" - This is running Ubuntu 16.04 (same as above)

We've confirmed it affects other users running Windows 10 and this box - i,e. it is not just me. This SO question summizes the issue perfectly: http://stackoverflow.com/q/33393077/1317935 . I dropped a 500 bounty on the question to try to get a solution - but nothing yet.

Note: it talks about not being able to clone - but I also see the regularly git commit error above, so I think it is likely the same issue

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.