2015-08-22 95 views
1

我在學習Udacity課程,他們讓我安裝Vagrant。但由於.box文件的大小我首先下載到本地從其他網絡,我得到這個tar文件trusty-server-cloudimg-i386-vagrant-disk1.tar。他們要我下載他們的文件夾fullstack。此文件夾包含以下結構:如何從本地安裝Vagrant VM

|--fullstack 
    |--vagrant 
     |--.vagrant 
     |--catalog 
     |--forum 
      |--forum.py 
      |--forum.sql 
      |--forumdb.py 
     |--tournament 
      |--tournament.py 
      |--tournament.sql 
      |--tournament_test.py 
     |--pg_config 
     |--Vagrantfile 

放浪你可以看到他們是如何從this link做。現在,當我在使用git bash通過vagrant up將以下代碼位置fullstack/vagrant都起牀:

$ vagrant up 
Bringing machine 'default' up with 'virtualbox' provider... 
==> default: Box 'ubuntu/trusty32' could not be found. Attempting to find and in 
stall... 
    default: Box Provider: virtualbox 
    defa 

ult: Box Version: >= 0 
==> default: Loading metadata for box 'ubuntu/trusty32' 
    default: URL: https://atlas.hashicorp.com/ubuntu/trusty32 
==> default: Adding box 'ubuntu/trusty32' (v20150818.0.0) for provider: virtualb 
ox 

現在,你可以在代碼中看到它向下正試圖從網上,我有下載.box的文件在本地下載,我的驅動器上有。我想編輯一些配置文件,這樣當我用vagrant up它應該使用本地文件trusty-server-cloudimg-i386-vagrant-disk1.tar文件來安裝。如果還需要請讓我在評論某些信息不應該去下載網上文件

default: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/trusty32/versions/20150818.0.0/providers/virtualbox.box 
    ==> default: Box download is resuming from prior download progress 
     default: Progress: 0% (Rate: 13410/s, Estimated time remaining: 5:35:56)) 

我會更新我的問題。

Vagrantfile:

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

VAGRANTFILE_API_VERSION = "2" 

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 
    config.vm.provision "shell", path: "pg_config.sh" 
    # config.vm.box = "hashicorp/precise32" 
    config.vm.box = "ubuntu/trusty32" 
    config.vm.network "forwarded_port", guest: 8000, host: 8000 
    config.vm.network "forwarded_port", guest: 8080, host: 8080 
    config.vm.network "forwarded_port", guest: 5000, host: 5000 
end 

pg_config.sh:

apt-get -qqy update 
apt-get -qqy install postgresql python-psycopg2 
apt-get -qqy install python-flask python-sqlalchemy 
apt-get -qqy install python-pip 
pip install bleach 
pip install oauth2client 
pip install requests 
pip install httplib2 
su postgres -c 'createuser -dRS vagrant' 
su vagrant -c 'createdb' 
su vagrant -c 'createdb forum' 
su vagrant -c 'psql forum -f /vagrant/forum/forum.sql' 

vagrantTip="[35m[1mThe shared directory is located at /vagrant\nTo access your shared files: cd /vagrant(B[m" 
echo -e $vagrantTip > /etc/motd 

當我嘗試添加這樣我得到以下錯誤:

$ vagrant box add mybox C:\Users\Rahul\Downloads\trusty-server-cloudimg-i386-va 
grant-disk1.tar 
c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize': 
the scheme file does not accept registry part: C:UsersRahulDownloadstrusty-serv 
er-cloudimg-i386-vagrant-disk1.tar (or bad hostname?) (URI::InvalidURIError) 
     from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:218:in ` 
new' 
     from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:218:in ` 
parse' 
     from c:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/common.rb:747:in ` 
parse' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/builtin/box_add.rb:465:in `metadata_url?' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/builtin/box_add.rb:77:in `block in call' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/builtin/box_add.rb:75:in `map' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/builtin/box_add.rb:75:in `call' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/warden.rb:34:in `call' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/builder.rb:116:in `call' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/runner.rb:66:in `block in run' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/u 
til/busy.rb:19:in `busy' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/a 
ction/runner.rb:66:in `run' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/comma 
nds/box/command/add.rb:89:in `execute' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/comma 
nds/box/command/root.rb:61:in `execute' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/c 
li.rb:42:in `execute' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/e 
nvironment.rb:301:in `cli' 
     from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/bin/vagrant:1 
74:in `<main>' 

編輯加了一些錯誤:

$ vagrant box add mybox C:/Udacity/trusty-server-cloudimg-i386-vagrant-disk1.ta 
r 
==> box: Box file was not detected as metadata. Adding it directly... 
==> box: Adding box 'mybox' (v0) for provider: 
    box: Unpacking necessary files from: file://C:/Udacity/trusty-server-cloudim 
g-i386-vagrant-disk1.tar 
    box: 
An error occurred while downloading the remote file. The error 
message, if any, is reproduced below. Please fix this error and try 
again. 

Couldn't open file /Udacity/trusty-server-cloudimg-i386-vagrant-disk1.tar 

回答

5

您可能需要添加如下的框。請參閱http://docs.vagrantup.com/v2/cli/box.html

vagrant box add yourbox file:///box-file-location/yourbox.box 
vagrant init yourbox 
vagrant up 
+0

我已經添加了什麼我得到 –

+0

@RahulShrivastava你可以當場在路徑的差異錯誤:這是由流浪拋出您輸入和其他的人嗎? – Alik

+0

@RahulShrivastava您是否試圖在您的Windows路徑中逃避反斜槓? – rockcode