我正在使用Windows 7 32位主机的框Ubuntu/trusty32使用Vagrant设置Rails环境。我陷入了bundle install --path=./vendor/bundle
。我有以下错误:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /vagrant/vendor/bundle/ruby/2.4.0/gems/nio4r-2.1.0/ext/nio4r
/home/vagrant/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20170911-24730-8nkvsn.rb extconf.rb
checking for unistd.h... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... yes
checking for sys/event.h... no
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile
Text file busy @ unlink_internal - ./siteconf20170911-24730-8nkvsn.rb
Gem files will remain installed in /vagrant/vendor/bundle/ruby/2.4.0/gems/nio4r-2.1.0 for inspection.
Results logged to /vagrant/vendor/bundle/ruby/2.4.0/extensions/x86-linux/2.4.0-static/nio4r-2.1.0/gem_make.out
An error occurred while installing nio4r (2.1.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.1.0'` succeeds before bundling.
In Gemfile:
rails_admin was resolved to 1.2.0, which depends on
rails was resolved to 5.0.6, which depends on
actioncable was resolved to 5.0.6, which depends on
nio4r
问题似乎是GEM nio4r
的问题。我尝试了这些:
-
gem install bundler
-
bundle update
-
gem uninstall nio4r
-
gem install nio4r
(成功安装了宝石) -
rm Gemfile.lock
-
bundle install
以上都没有作用。我也尝试了:
sudo apt-get install ruby2.2-dev
但找不到包裹。
E: Unable to locate package ruby2.2-dev
E: Couldn't find any package by regex 'ruby2.2-dev'
错误主要地址为消息Text file busy @ unlink_internal - ./siteconf20170911-24730-8nkvsn.rb
。我找到了一个解决方案,遵循了文章中描述的步骤。
通过将捆绑路径更改为VM本地的目录(不在共享文件夹上)使错误消失了。
-
创建一个新目录
mkdir ~/.bundles
-
将其添加到
/vagrant/.bundle/config
BUNDLE_PATH: "/home/vagrant/.bundles/PROJECT_NAME_HERE" BUNDLE_DISABLE_SHARED_GEMS: "1"
- 运行
bundle install