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

标签 ruby rubygems rake

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

我正在使用帖子 here ,具有相同的目录结构,以创建 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

//网络 session .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

//拉克文件

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

最佳答案

我收到这个错误是因为我还没有用 git 提交我的更新。

s.files         = `git ls-files`.split("\n")

那一行是直接使用git,可能导致这个错误。就这样

git add .
git commit -a -m "init"

关于ruby - 执行 gem ... ["extconf.rb", ...] 不是文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6256743/

相关文章:

ruby-on-rails - 使用 ror 处理网络服务响应

ruby - 如何让 CTRL-] 获取 Ruby 方法名称中的 '?' ?

mysql - Ruby on Rails mysql2 gem 故障排除

ruby - 使用来自 GitLab 的私有(private) gem 构建 Ruby 项目

windows - 抽取 Assets :precompile doesn't work (rails 3. 1.1)

ruby-on-rails - 更改用于生成 Rails 应用程序文档的 RDoc 模板

ruby - 为什么我不能将单例方法附加到另一个对象?

ruby - Ruby 1.9.3 中的并行测试有多并行?

ruby-on-rails - 创建自定义 move_up 路线和 move_down 操作/路线 Rails

带 Rake 的 RubyMine 调试器?