为什么每次我将流浪汉ssh进入我的流浪盒时都必须运行bundle install

时间:2017-06-10 21:34:59

标签: ruby-on-rails vagrant

我从去年年底开始使用Vagrant文​​件和一个全新的rails项目,出于某种原因,每当我vagrant ssh进入框中时,它都无法找到某个宝石,我必须运行bundle install

以下是我的Vagrantfile,任何帮助将不胜感激。谢谢!

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

VAGRANTFILE_API_VERSION = "2"

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

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "eyefodder/precise64-utf8"
  config.vm.host_name = 'myproj'

  config.vm.network :forwarded_port, guest: 3000, host: 3000
  # config.vm.network :forwarded_port, id: 'ssh', guest: 22, host: 2222

  config.vm.synced_folder "./puppet", "/etc/puppet"
  config.vm.synced_folder 'dotfiles', '/dotfiles'
  config.vm.synced_folder '../reports', '/reports'
  config.vm.synced_folder "../", "/app", type: "rsync", rsync__exclude: [".git/", "ops/*", "reports/",  "tmp/", "log/", ".#*"]

  config.vm.provider 'virtualbox' do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"]
    vb.name = 'myproj'
  end

  config.vm.provision 'shell', path: 'install_apt_packages.sh'
  config.vm.provision 'shell', path: 'build_ruby_from_source.sh'
  config.vm.provision 'shell', path: 'install_puppet_modules.sh'
  config.vm.provision "puppet" do |puppet|
    puppet.module_path = 'puppet/modules'
    puppet.hiera_config_path = "puppet/hiera.yaml"
    puppet.working_directory = "/etc/puppet"
    puppet.environment_path = "puppet/environments"
    puppet.environment = "dev"
  end

  config.trigger.before [:up, :reload], :stdout => true do
    run "mkdir -p ../reports"
    run "mkdir -p ../public/uploads"
    run "sh ./setup_guest_bash_profile.sh"
  end
end

修改

似乎每当我杀死我的rails服务器时,我必须再次运行bundle install才能启动它或查看rails控制台

1 个答案:

答案 0 :(得分:1)

rsync is a default type with the specific property

The rsync synced folder does a one-time one-way sync from the machine running to the machine being started by Vagrant.

so the changes are not reflected (in somewhat) real time, you need to force your system to sync again the files

make the change in your Vagrantfile

  config.vm.synced_folder "../", "/app", type: "rsync", rsync__exclude: [".git/", "ops/*", "reports/",  "tmp/", "log/", ".#*"], rsync_auto: true

and then after you have vagrant up you will need to run

$ vagrant rsync-auto

so vagrant will force rsync to sync your files when there's some change. Everything should work smoothly