gpt4 book ai didi

ruby-on-rails - Rake des 不知道如何构建任务 'compile' ,如何跟踪这个错误?

转载 作者:数据小太阳 更新时间:2023-10-29 07:36:28 24 4
gpt4 key购买 nike

我收到错误消息“不知道如何构建任务‘编译’”。我还是 ruby​​ 的新手,但所有这些痕迹似乎都指向我没有编写的代码,那么我应该如何处理这个错误?

#> rake compile --tracerake 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 numberputs 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'  endend# clean environment by removing old binariesoverride_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  endend# initialize directory structuretask :init do  FileCheckCreateDirectory($myDir + '/bin')  FileCheckCreateDirectory($myDir + '/tmp')end# compile module and install to liboverride_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  endend# show commandstask :help do  show_helpend# build module and installtask :build => [:init, :clean, :compile]Bundler::GemHelper.install_tasks# remove any temporary filesdef clear_tmp  FileUtils.rm_rf(Dir.glob($myDir + '/tmp/*'))end# display help screendef 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.')  putsend

最佳答案

好吧,这个错误消息真的一点用都没有……

问题是由于 gemspec 中的正则表达式不匹配,Gem::Specification.executables 为空。当我遍历它时(请参阅 Rakefile),没有构建 extensiontask,因此出现了误导性错误。

关于ruby-on-rails - Rake des 不知道如何构建任务 'compile' ,如何跟踪这个错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14115063/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com