执行gem时... ["extconf.rb",...]不是文件

Ale*_*ans 18 ruby rake rubygems

我正在尝试围绕C扩展构建一个ruby gem.C扩展使用ruby extconf.rb; make; sudo make install例程编译好,但是当我尝试使用rake构建gem时,该过程终止于此跟踪底部的错误.

我在这里使用相同目录结构的帖子来创建gem.

我的配置有什么问题?我的gemspec和Rakefile位于跟踪之下(gem称为netconf).

//跟踪

** Execute copy:netconf:i686-linux:1.9.2
install -c tmp/i686-linux/netconf/1.9.2/netconf.so lib/netconf/netconf.so
** Execute compile:netconf:i686-linux
** Execute compile:i686-linux
** Execute compile
** Invoke chmod (first_time)
** Execute chmod
** Execute build
rake aborted!
ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
    ["extconf.rb", "netconf.o", "netconf.so"] are not files
Run Code Online (Sandbox Code Playgroud)

// netconf.gemspec

# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "netconf/version"

Gem::Specification.new do |s|
  s.name        = "netconf"
  s.version     = Netconf::VERSION
  s.authors     = ["..."]
  s.email       = ["..."]
  s.homepage    = "..."
  s.summary     = %q{A tool to access and write Ubuntu network configuration}
  s.description = %q{Uses ifconfig and other C system calls to access network configurations on a Ubuntu install.}

  s.rubyforge_project = "netconf"

  s.files         = `git ls-files`.split("\n")
  s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
  s.require_paths = ["lib"]
  s.extensions    = ["ext/netconf/extconf.rb"]
end
Run Code Online (Sandbox Code Playgroud)

// Rakefile

require 'rake'
require 'rake/extensiontask'
require 'bundler'

Rake::ExtensionTask.new("netconf") do |extension|
  extension.lib_dir = "lib/netconf"
end

task :chmod do
  File.chmod(0775, 'lib/netconf/netconf.so')
end

task :build => [:clean, :compile, :chmod]

Bundler::GemHelper.install_tasks
Run Code Online (Sandbox Code Playgroud)

cbr*_*ron 45

我收到此错误是因为我还没有用git提交我的更新.

s.files         = `git ls-files`.split("\n")
Run Code Online (Sandbox Code Playgroud)

该行直接使用git,可能导致此错误.做就是了

git add .
git commit -a -m "init"
Run Code Online (Sandbox Code Playgroud)

  • 谢谢你分享这个,你给我带来了很多麻烦.让文件上演(不一定是我提供的所有内容^ _ ^) (4认同)