[英]Why do I have to run bundle install every time I vagrant ssh into my vagrant box
I'm using a Vagrant file from late last year with a brand new rails project and for some reason, every time I vagrant ssh
into the box, it can't find a certain gem and I have to run bundle install
. 我正在使用来自去年下半年的Vagrant文件以及一个全新的Rails项目,由于某种原因,每当我将
vagrant ssh
放到盒子中时,它都找不到某个gem,因此我必须运行bundle install
。
Below is my Vagrantfile, any help would be appreciated. 下面是我的Vagrantfile,任何帮助将不胜感激。 Thanks!
谢谢!
# -*- 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
Edit 编辑
Also seems whenever I kill my rails server I have to run bundle install
again in order to start it up or view a rails console 似乎每当我杀死Rails服务器时,都必须再次运行
bundle install
才能启动它或查看Rails控制台
rsync
is a default type with the specific property rsync
是具有特定属性的默认类型
The rsync synced folder does a one-time one-way sync from the machine running to the machine being started by Vagrant.
rsync synced文件夹从运行的计算机到由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 在您的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 up
您将需要运行
$ vagrant rsync-auto
so vagrant will force rsync to sync your files when there's some change. 因此,发生变化时,vagrant将强制rsync同步文件。 Everything should work smoothly
一切都应该顺利进行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.