加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rake des不知道如何构建任务’compile’,如何

发布时间:2020-12-17 02:14:59 所属栏目:百科 来源:网络整理
导读:我收到错误“不知道如何构建任务’编译’”.我仍然是 ruby的新手,但是所有这些痕迹似乎都指向我没写过的代码,那么我应该怎么做这个错误呢? # rake compile --tracerake aborted!Don't know how to build task 'compile'/usr/local/rvm/gems/ruby-1.9.3-p286
我收到错误“不知道如何构建任务’编译’”.我仍然是 ruby的新手,但是所有这些痕迹似乎都指向我没写过的代码,那么我应该怎么做这个错误呢?

#> rake compile --trace
rake aborted!
Don't know how to build task 'compile'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task_manager.rb:49:in `[]'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:142:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/bin/rake:33:in `'
/usr/local/rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `'

这是Rakefile:

require 'bundler/gem_tasks'
require 'rake'
require 'rake/extensiontask'
$myDir = File.dirname(__FILE__)

require $myDir + '/lib/Q/console.rb'
require $myDir + '/lib/Q/version.rb'
require $myDir + '/lib/Q/rakeoverride.rb'
require $myDir + '/lib/Q/filetools.rb'

# this just prints out a header and gems version number
puts Q::Console.txHead('Q-Pool Ruby Extension Q V' + Q::VERSION)

# load specifiation from gemspec and create
# a task for every extension file in
# executables.
spec = Gem::Specification.load('Q.gemspec')
spec.executables.each do |f|
  Rake::ExtensionTask.new('Q',spec) do |ext|
    # extension file is *.so,so we need
    # to chop the extension to get the name
    ext.name    = f.gsub(/.so$/,'')
    ext.tmp_dir = 'tmp'
    ext.lib_dir = 'bin'
  end
end

# clean environment by removing old binaries
override_task :clean do
  puts Q::Console.txNote('cleaning...')
  clear_tmp
  begin
    Rake::Task["clean:original"].invoke
    puts Q::Console.txConfirm('...cleaned!')
  rescue
    puts Q::Console.txAlert('could not clean: ' + $!.to_s)
    exit
  end
end

# initialize directory structure
task :init do
  FileCheckCreateDirectory($myDir + '/bin')
  FileCheckCreateDirectory($myDir + '/tmp')
end

# compile module and install to lib
override_task :compile do
  puts Q::Console.txNote('compiling...')
  begin
    Rake::Task["compile:original"].invoke
    puts Q::Console.txConfirm('...compiled!')
  rescue Exception
    puts Q::Console.txAlert('could not compile: ' + $!.to_s)
    exit
  ensure
    clear_tmp
    puts
  end
end

# show commands
task :help do
  show_help
end

# build module and install
task :build => [:init,:clean,:compile]

Bundler::GemHelper.install_tasks

# remove any temporary files
def clear_tmp
  FileUtils.rm_rf(Dir.glob($myDir + '/tmp/*'))
end

# display help screen
def show_help
  Q::Console.out(Q::Console.txCode('build') + '      performs init,clean and compile.')
  Q::Console.out(Q::Console.txCode('clean') + '      removes any old binaries from temp-dir.')
  Q::Console.out(Q::Console.txCode('compile') + '    compiles binaries.')
  Q::Console.out(Q::Console.txCode('help') + '       enlists rake-commands (this page).')
  Q::Console.out(Q::Console.txCode('init') + '       creates gems directory structure.')
  puts
end

解决方法

好吧,这个错误消息根本没什么用处……

问题是由于gemspec中的正则表达式不匹配,Gem :: Specification.executables为空.当我迭代它(参见Rakefile)时,没有扩展任务构建,因此误导错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读