-
-
Save lotreal/1e16a3fe24191ec86137 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
GEMS=$(cat <<EOF | |
childprocess-0.5.8.gem | |
ffi-1.9.10.gem | |
little-plugger-1.1.4.gem | |
micromachine-1.1.0.gem | |
multi_json-1.11.1.gem | |
net-ssh-2.9.2.gem | |
rest-client-1.6.9.gem | |
vagrant-vbguest-0.11.0.gem | |
EOF | |
) | |
CACHE=$HOME/.vagrant.d/gems/cache | |
mkdir -p $CACHE | |
for GEM in $GEMS | |
do | |
URL=https://gems.ruby-china.com/$GEM | |
echo "Downloading: $URL" | |
curl --progress-bar -o $CACHE/$GEM -L $URL | |
done | |
vagrant plugin install vagrant-vbguest |
good
折腾了很久,终于看到解决方案。赞!
已更新脚本:
curl --progress-bar -o $CACHE/$GEM -L $URL
解决了 302 转向下载错误的问题。
fuck gfw
taobao 的 ruby 镜像已经没有了,改成 ruby china 来提供镜像了:
https://gems.ruby-china.com/
麻烦楼主更新一下脚本
taobao 的 ruby 镜像已经没有了,改成 ruby china 来提供镜像了:
https://gems.ruby-china.com/
麻烦楼主更新一下脚本
已更新,谢谢提供
你好,执行这个脚本遇到了以下问题。
环境 windows10
$ vagrant -v
Vagrant 2.2.14
VirtualBox 图形用户界面
版本 6.1.16 r140961 (Qt5.6.2)
$ sh install-vagrant-vbguest.sh
Downloading: https://gems.ruby-china.com/childprocess-0.5.8.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/ffi-1.9.10.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/little-plugger-1.1.4.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/micromachine-1.1.0.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/multi_json-1.11.1.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/net-ssh-2.9.2.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/rest-client-1.6.9.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/vagrant-vbguest-0.11.0.gem
######################################################################## 100.0%
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.6.0/rubygems/package/tar_header.rb:130:in strict_oct': "arset=ut" is not an octal string (ArgumentError) from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.6.0/rubygems/package/tar_header.rb:109:in
from'
你好,执行这个脚本遇到了以下问题。
环境 windows10
$ vagrant -v
Vagrant 2.2.14VirtualBox 图形用户界面
版本 6.1.16 r140961 (Qt5.6.2)$ sh install-vagrant-vbguest.sh
Downloading: https://gems.ruby-china.com/childprocess-0.5.8.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/ffi-1.9.10.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/little-plugger-1.1.4.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/micromachine-1.1.0.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/multi_json-1.11.1.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/net-ssh-2.9.2.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/rest-client-1.6.9.gem
######################################################################## 100.0%
Downloading: https://gems.ruby-china.com/vagrant-vbguest-0.11.0.gem
######################################################################## 100.0%
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.6.0/rubygems/package/tar_header.rb:130:instrict_oct': "arset=ut" is not an octal string (ArgumentError) from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.6.0/rubygems/package/tar_header.rb:109:in
from'
你好,已经几年,依赖包的版本号估计需要手动改一下。另外,脚本没有在 Windows 环境下测试过。
升级 VirtualBox 或 Vagrant 虚拟机时,常遇到 VirtualBox guest additions 版本不一致,导致 vagrant 启动失败的问题。
解决方式就是安装合适的 vbguest additions 版本。使用 vagrant 插件 vagrant-vbguest 可以自动处理这个问题,非常方便。
安装方法是:
但是,根据中国的相关法律法规,gem 不予下载,连接会被重置。就算在 $HOME/.gemrc 里设置了国内镜像,都无法解决这个问题。
这是因为 vagrant 的插件使用了单独的 ruby 环境。而使用上面的脚本,把所依赖的 gem 下载到 vagrant 的 gem 缓存里,就可以成功安装这个插件了。