【问题标题】:While executing gem ... ["extconf.rb", ...] are not files执行 gem ... ["extconf.rb", ...] 时不是文件
【发布时间】:2011-06-06 19:03:03
【问题描述】:

我正在尝试围绕 C 扩展构建一个 ruby​​ gem。 C 扩展使用 ruby extconf.rb; make; 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

// 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

// 瑞克文件

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

【问题讨论】:

  • This 可能是相关的
  • 我看到了那个问题;谢谢你的头。我正在使用 rake-compiler,但我无法找到有关此特定错误的任何信息(而且我很确定我需要/想要一个本机 C 扩展,因为我的目标是单个嵌入式平台)。

标签: ruby rubygems rake


【解决方案1】:

我收到此错误是因为我尚未使用 git 提交更新。

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

该行直接使用 git,可能导致此错误。做吧

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

【讨论】:

  • 感谢您的分享,您为我省去了很多麻烦。暂存文件(不一定要提交就是我所需要的全部 ^ _ ^)
【解决方案2】:

FWIW,我遇到了类似的问题

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

曾经

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

,单引号阻止文件列表正确拆分。更改为双引号为我解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-07
    相关资源
    最近更新 更多