Giter Club home page Giter Club logo

rake's Introduction

RAKE – Ruby Make

home

github.com/ruby/rake

bugs

github.com/ruby/rake/issues

docs

ruby.github.io/rake

Description

Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.

Rake has the following features:

  • Rakefiles (rake’s version of Makefiles) are completely defined in standard Ruby syntax. No XML files to edit. No quirky Makefile syntax to worry about (is that a tab or a space?)

  • Users can specify tasks with prerequisites.

  • Rake supports rule patterns to synthesize implicit tasks.

  • Flexible FileLists that act like arrays but know about manipulating file names and paths.

  • A library of prepackaged tasks to make building rakefiles easier. For example, tasks for building tarballs. (Formerly tasks for building RDoc, Gems, and publishing to FTP were included in rake but they’re now available in RDoc, RubyGems, and rake-contrib respectively.)

  • Supports parallel execution of tasks.

Installation

Gem Installation

Download and install rake with the following.

gem install rake

Usage

Simple Example

First, you must write a “Rakefile” file which contains the build rules. Here’s a simple example:

task default: %w[test]

task :test do
  ruby "test/unittest.rb"
end

This Rakefile has two tasks:

  • A task named “test”, which – upon invocation – will run a unit test file in Ruby.

  • A task named “default”. This task does nothing by itself, but it has exactly one dependency, namely the “test” task. Invoking the “default” task will cause Rake to invoke the “test” task as well.

Running the “rake” command without any options will cause it to run the “default” task in the Rakefile:

% ls
Rakefile     test/
% rake
(in /home/some_user/Projects/rake)
ruby test/unittest.rb
....unit test output here...

Type “rake –help” for all available options.

Resources

Rake Information

Presentations and Articles about Rake

Other Make Re-envisionings …

Rake is a late entry in the make replacement field. Here are links to other projects with similar (and not so similar) goals.

Credits

Jim Weirich

Who originally created Rake.

Ryan Dlugosz

For the initial conversation that sparked Rake.

Nobuyoshi Nakada <[email protected]>

For the initial patch for rule support.

Tilman Sauerbeck <[email protected]>

For the recursive rule patch.

Eric Hodel

For aid in maintaining rake.

Hiroshi SHIBATA

Maintainer of Rake 10 and later

License

Rake is available under an MIT-style license.

:include: MIT-LICENSE


Other stuff

Author

Jim Weirich <[email protected]>

Requires

Ruby 2.0.0 or later

License

Copyright Jim Weirich. Released under an MIT-style license. See the MIT-LICENSE file included in the distribution.

Warranty

This software is provided “as is” and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.

Historical

Rake was originally created by Jim Weirich, who unfortunately passed away in February 2014. This repository was originally hosted at github.com/jimweirich/rake, however with his passing, has been moved to ruby/rake.

You can view Jim’s last commit here: github.com/jimweirich/rake/tree/336559f28f55bce418e2ebcc0a57548dcbac4025

You can read more about Jim at Wikipedia.

Thank you for this great tool, Jim. We’ll remember you.

rake's People

Contributors

amatsuda avatar aycabta avatar colby-swandale avatar deivid-rodriguez avatar dependabot[bot] avatar drbrain avatar epidemian avatar eregon avatar foobarwidget avatar grzuy avatar hsbt avatar jeremyevans avatar jimweirich avatar keathley avatar ksss avatar luislavena avatar markdblackwell avatar matzbot avatar michaeljbishop avatar nobu avatar olleolleolle avatar pskocik avatar pvdb avatar quix avatar raggi avatar randycoulman avatar satoryu avatar tnir avatar tscholz avatar yuki24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rake's Issues

specifying bash (instead of sh) to run shell commands

Update

A makeshift solution is described here - http://stackoverflow.com/questions/17044325/use-bin-bash-for-x-in-ruby

If /bin/sh is hardcoded into ruby, it would make this more of an issue for ruby rather than a rake (feel free close/delete this issue).

Original Issue

Is there a way to configure rake to use bash (/bin/bash) rather than sh (/bin/sh) as the default shell interpreter?

I'd like to take advantage of BASH-centric features in rake, such as process substitution, which are not implemented in sh:

For example,

task :default do
  `cat <( seq 1 10 )`
end

produces the error:

sh: 1: Syntax error: "(" unexpected

since sh appears to be the default Rake shell.

Something analogous to setting SHELL:=/bin/bash in Makefiles would be useful if it doesn't already exist.

My googling has come up empty regarding this feature in Rake.

Further reading

OptionParser doesn't work for rake 10.4.2?

The following code has variable results:

require 'optparse'
namespace :schedule do |args|

  desc "Create schedule entries for recurring events"
  task :create_recurring => :environment do
    puts "starting schedule creation" 
    options = {}
    optparse = OptionParser.new(args) do |opts|
      opts.on("--from_date={from_date}", "Date to start creating Schedules") do |from_date|
        options[:from_date] = from_date
      end
      opts.on("-c","--calendar_id={calendar_id}", "Calendar to create Schedules for") do |calendar_id|
        options[:calendar_id] = calendar_id
      end
      opts.on("-e", "--event_id={event_id}", "Event to create Schedules for") do |event_id|
        options[:event_id] = event_id
      end
    end
    begin 
      optparse.parse!(ARGV[1..-1])
    rescue OptionsParser::InvalidOption => e
      puts "invalid option : e.inspect"
    end

    puts "options #{options.inspect}"
    exit 0  
  end
end

rake schedule:create_recurring -- --from_date="2015-08-30"
invalid option: --from_date=2015-08-30

rake schedule:create_recurring -- --c 1
DL is deprecated, please use Fiddle
starting schedule creation
options {:calendar_id=>"1"}

rake schedule:create_recurring -- --e 1
No output

rake schedule:create_recurring -- --c 1 --e 1
No output

rake schedule:create_recurring -- --c 1 --e 1 --from_date=foo
No output

rake schedule:create_recurring -- --c 1 --from_date=foo
invalid option: --from_date=foo

Someone on StackOverflow indicates they can get this to work with Rake 0.96, so it sounds like a Rake bug?

Rake 10.4.2 segfaults on ruby 2.2.3

Here is minimal reproducible case:

task.rake

require 'rake/tasklib'

class CapistranoTask < ::Rake::TaskLib
  def initialize
    namespace(:unicorn, &method(:define))
  end

  def define(*)
    namespace :config do

    end
  end
end

CapistranoTask.new

in Rakefile

Rake.application.add_import('./task.rake')

and just run rake whatever.

It segfaults with:

ruby-2.2.3/lib/ruby/2.2.0/rake/task_manager.rb:210: [BUG] Stack consistency error (sp: 65, bp: 64)
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   for more details.

-- Control frame information -----------------------------------------------
c:0018 p:0081 s:0065 e:000063 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task_manager.rb:210
c:0017 p:0095 s:0059 e:000058 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/dsl_definition.rb:147
c:0016 p:0014 s:0054 e:000053 METHOD /Users/mikz/Developer/3scale/deploy/test/1c47d36b083961e1291b/unicorn.rake:5 [FINISH]
c:0015 p:---- s:0051 e:000050 CFUNC  :new
c:0014 p:0040 s:0048 e:000047 TOP    /Users/mikz/Developer/3scale/deploy/test/1c47d36b083961e1291b/unicorn.rake:15 [FINISH]
c:0013 p:---- s:0046 e:000045 CFUNC  :load
c:0012 p:0009 s:0042 e:000041 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28
c:0011 p:0024 s:0038 e:000037 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/default_loader.rb:10
c:0010 p:0084 s:0034 e:000033 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:767
c:0009 p:0192 s:0027 E:0001a0 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:697
c:0008 p:0007 s:0022 e:000021 BLOCK  /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:94
c:0007 p:0006 s:0020 e:000019 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176
c:0006 p:0007 s:0016 e:000015 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:93
c:0005 p:0013 s:0013 e:000012 BLOCK  /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:77
c:0004 p:0006 s:0011 e:000010 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176
c:0003 p:0007 s:0007 e:000006 METHOD /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75
c:0002 p:0040 s:0004 E:001ab0 EVAL   /Users/mikz/.rvm/rubies/ruby-2.2.3/bin/rake:37 [FINISH]
c:0001 p:0000 s:0002 E:0006e0 TOP    [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/mikz/.rvm/rubies/ruby-2.2.3/bin/rake:37:in `<main>'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:697:in `raw_load_rakefile'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb:767:in `load_imports'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/default_loader.rb:10:in `load'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/Users/mikz/Developer/3scale/deploy/test/1c47d36b083961e1291b/unicorn.rake:15:in `<top (required)>'
/Users/mikz/Developer/3scale/deploy/test/1c47d36b083961e1291b/unicorn.rake:15:in `new'
/Users/mikz/Developer/3scale/deploy/test/1c47d36b083961e1291b/unicorn.rake:5:in `initialize'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/dsl_definition.rb:147:in `namespace'
/Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task_manager.rb:210:in `in_namespace'

-- C level backtrace information -------------------------------------------
0   ruby                                0x0000000103a6fb65 rb_vm_bugreport + 149
1   ruby                                0x0000000103912524 rb_bug + 468
2   ruby                                0x0000000103a51fc3 vm_exec_core + 17427
3   ruby                                0x0000000103a60941 vm_exec + 129
4   ruby                                0x0000000103a69382 rb_call0 + 674
5   ruby                                0x000000010397a159 rb_class_new_instance + 41
6   ruby                                0x0000000103a6da85 vm_call_cfunc + 1797
7   ruby                                0x0000000103a6cb4f vm_call_method + 895
8   ruby                                0x0000000103a51240 vm_exec_core + 13968
9   ruby                                0x0000000103a60941 vm_exec + 129
10  ruby                                0x0000000103a6088d rb_iseq_eval + 285
11  ruby                                0x00000001039208eb rb_load_internal0 + 315
12  ruby                                0x000000010392059a rb_f_load + 186
13  ruby                                0x0000000103a6da85 vm_call_cfunc + 1797
14  ruby                                0x0000000103a51240 vm_exec_core + 13968
15  ruby                                0x0000000103a60941 vm_exec + 129
16  ruby                                0x0000000103a61518 rb_iseq_eval_main + 504
17  ruby                                0x000000010391b534 ruby_exec_internal + 148
18  ruby                                0x000000010391b45e ruby_run_node + 78
19  ruby                                0x00000001037c727f main + 79

-- Other runtime information -----------------------------------------------

* Loaded script: /Users/mikz/.rvm/rubies/ruby-2.2.3/bin/rake

* Loaded features:

    0 enumerator.so
    1 rational.so
    2 complex.so
    3 encdb.so
    4 trans/transdb.so
    5 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/unicode_normalize.rb
    6 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/x86_64-darwin14/rbconfig.rb
    7 thread.rb
    8 thread.so
    9 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/compatibility.rb
   10 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/defaults.rb
   11 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/deprecate.rb
   12 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/errors.rb
   13 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb
   14 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/requirement.rb
   15 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/platform.rb
   16 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/basic_specification.rb
   17 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/stub_specification.rb
   18 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/util/stringio.rb
   19 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/specification.rb
   20 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/exceptions.rb
   21 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb
   22 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb
   23 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
   24 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems.rb
   25 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/dependency.rb
   26 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/path_support.rb
   27 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/version.rb
   28 etc.so
   29 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/fileutils.rb
   30 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/singleton.rb
   31 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/optparse.rb
   32 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/ostruct.rb
   33 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/ext/module.rb
   34 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/ext/core.rb
   35 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/ext/string.rb
   36 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/early_time.rb
   37 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/late_time.rb
   38 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/ext/time.rb
   39 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/alt_system.rb
   40 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/win32.rb
   41 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/linked_list.rb
   42 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/cpu_counter.rb
   43 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/scope.rb
   44 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task_argument_error.rb
   45 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rule_recursion_overflow_error.rb
   46 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/shellwords.rb
   47 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task_manager.rb
   48 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/cloneable.rb
   49 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/file_utils.rb
   50 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/file_utils_ext.rb
   51 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/pathmap.rb
   52 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/file_list.rb
   53 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/set.rb
   54 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/promise.rb
   55 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/thread_pool.rb
   56 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/private_reader.rb
   57 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/thread_history_display.rb
   58 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/trace_output.rb
   59 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/application.rb
   60 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_module.rb
   61 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/pseudo_status.rb
   62 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task_arguments.rb
   63 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/invocation_chain.rb
   64 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/invocation_exception_mixin.rb
   65 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/task.rb
   66 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/file_task.rb
   67 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/file_creation_task.rb
   68 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/multi_task.rb
   69 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/dsl_definition.rb
   70 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/default_loader.rb
   71 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/name_space.rb
   72 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/backtrace.rb
   73 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake.rb
   74 /Users/mikz/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/tasklib.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Don't forget to include the above Crash Report log file.
For details: http://www.ruby-lang.org/bugreport.html

It segfaults the same way on Linux machine with Ruby 2.2.2.

Will report it to Ruby also.

task.comment and friends are nil

Example:

desc 'Hello'
task :hello do
  p task
  p task.name
  p task.comment
  p task.full_comment
  p task.to_s

  p Rake::Task[:hello]
  p Rake::Task[:hello].name
  p Rake::Task[:hello].comment
  p Rake::Task[:hello].full_comment
  p Rake::Task[:hello].to_s
end

Output:

$ bundle exec rake hello
<Rake::Task  => []>
""
nil
nil
""
<Rake::Task hello => []>
"hello"
nil
nil
"hello"

(Or if this is the intended behavior then the doc is missing some explanations)

Tips from http://stackoverflow.com/questions/8781263 don't work and Rake::TaskManager.record_task_metadata seems to be set to true already.

btw, feels awkward to use desc and then access to it via task.comment instead of task.desc or task.description.

Make job submission system configurable

I guess that parallel execution of build jobs is also supported by your software.
These jobs will be run by a local build environment so far. It can happen that the computing resources can become too limited for a challenging data processing application there.

I suggest to extend corresponding resources with capabilities from distributed systems. Some programming interfaces are available for such a purpose.
How do you think about to make it possible to choose from various job submission systems by configuration variables?

Marking tasks as :phony fails to prevent rebuild

The :phony task fails to prevent rebuild of FileTasks dependent on non-file tasks.

lib/rake/phony.rb

# Defines a :phony task that you can use as a dependency. This allows
# file-based tasks to use non-file-based tasks as prerequisites
# without forcing them to rebuild.
#
# See FileTask#out_of_date? and Task#timestamp for more info.

require 'rake'

task :phony

Rake::Task[:phony].tap do |task|
  def task.timestamp # :nodoc:
    Time.at 0
  end
end

Code reproducing bug

require 'rake/phony'

task :default => 'final.file'

file 'final.file' => ['source.file', :intermediate] do |f|
  touch f.name
end

# Marked as phony, so should not force FileTask to rebuild
task :intermediate => [:phony] do |t|
  puts "#{t.name} task"
end

Bug demo

$ touch source.file      # Create the source file
$ rake                   # Run Rake to build 'final.file'
intermediate task
touch final.file
$ rake                   # Rake should NOT rebuild, but does.     <<<<<<<<
intermediate task
touch final.file

Mentioned here

Tasks that take arguments are only run for first set of arguments.

If you have a task that takes an argument, eg:

task "hi", [:name] do |t, args|
  puts "hi #{args.name}"
end

and you want to run more than one invocation of the task with different arguments, eg:

rake hi[world] hi[there]

then only the first task is run, so in this case the output is:

$ rake hi[world] hi[there]
hi world

though my expected output would be

$ rake hi[world] hi[there]
hi world
hi there

when run with verbose the output is

rake -vt -f test.rakefile hi[world] hi[there]
** Invoke hi (first_time)
** Execute hi
hi world
** Invoke hi 

which makes me think it's being filtered out as it thinks it's already been run.

how to stay on the remote server

With the simple Rakefile:

require 'rake'

desc "login app1.dev"
task :app1 do
  command="ssh app1.dev.example.com bash"
  system(command)
end

When run rake app1, it is no prompt, I have to ctrl+c to cancel it.

if I change to command="ssh app1.dev.example.com pwd", show me the path, exist, and back to my local shell.

What I need is, after login app1.dev, stay and I can continuos the job on server app1.dev

Description is cut off when running `rake -T` if the description contains dots followed by (white) space

Let's assume the following Rakefile:

desc 'Have dots .. in the description'
task :odd do
  puts "doing soething useful..."
end

When I run rake -Tin the same directory I get this:

rake -T
rake odd  # Have dots .

Notice that the description is cut off after the first dot, even though the description i not particularly long.

However, if there's no space after the two dots (desc 'Have dots ..in the description'), then the complete description is printed:

#rake -T
rake odd  # Have dots ..in the description

Notes:

  • When using a non-breaking space (ALT-spacebar on OS X) directly after the dots, the complete description is printed as well. This can be used as a workaround.
  • It doesn't matter whether or not the dots appear consecutively in the description. Even with desc 'Have dots . in . the description'the text it cut off.

I consider this cutting off of text from the description a bug, since it even happens in relatively short descriptions and other non-dot descriptions of the same length are not cut off either.

Context:

  • OS X 10.11.3 (15D21)
  • rvm 1.26.11
  • Ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
  • Rake version 10.5.0

Hoe not found (documentation)

I cloned the repository and ran rake from the main directory. This produced the following error:

Williams-iMac:rake williamentriken$ rake
rake aborted!
LoadError: cannot load such file -- hoe
/Users/williamentriken/Developer/rake/Rakefile:18:in `<top (required)>'
(See full trace by running task with --trace)
Williams-iMac:rake williamentriken$

There was no mention of this in CONTRIBUTING. Also, "hoe" appears to be a generic word, so searching for the error is difficult on Google.

Using Mac OSX 10.11.1 (15B30a), and rake version 10.4.2.

Task description containing a space after a period.

In my Rakefile if for a particular task i specify the description as desc "foo.bar" then the description appears correctly when i run rake -T as # foo.bar. But if i enter the description as desc "foo. bar"(space after the period), then only # foo shows up when i run rake -T. Am i missing something here or is this a bug ?

Stack Level Too Deep in 10.4.2 Rake.application.run

I use Cruise control an was notified of failing builds on the latest update to two of my projects. The problem was a call to

bundle exec rake -v --nosearch --trace -e "Rake.application.run"

That call returned

rake aborted!
rake aborted!

So I dug a bit deeper and found that the real issue is probably:

bundle exec rake -v --nosearch --trace -e "handle_options"

rake aborted!
SystemStackError: stack level too deep

The stack level error "goes away" when using 10.3.2

rake gem won't install

When running gem install rake I get the following error: ERROR: While executing gem ... (OpenSSL::X509::StoreError)

Ruby seems to be able to install other gems just fine...

Rake::FileUtils#sh and #ruby has sematics different from that of Kernel#spawn

Hello!
I was trying to redirect shell command output using rake's #sh, or #ruby. Documentation told me, that semantics is the same as Kernel#exec has (and it is the same as Kernel#spawn). So I tried to use:

ruby('-e', 'puts "hello world"', out: './tst.out' )

But actually semantic differs: FileUtils#sh removes the last argument to check its :verbose and :noop keys, so it removes redirection keys. I found a solution, which is not much more difficult:

ruby('-e', 'puts "hello world"', {out: './tst.out'}, {})

I'm not sure if it is possible and reasonable to fix behavior at a moment, but I think it's worth being noted in a documentation. Redirection to a file is a very common task when you rewrite bash scripts into rake, so an example would be very useful.

Also I'd appreciate if you describe how sh with separate ARGV arguments can be used for piping several commands.

Running `rake anything` also runs rspec in 10.4.0

Affected Rake version

rake 10.4.0

Not Affected Rake version

rake 10.3.2

Description

Say I run rake db:migrate:status

It would run the following:
/Users/PikachuEXE/.rvm/rubies/ruby-2.1.5/bin/ruby -I/Users/PikachuEXE/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.1.7/lib:/Users/PikachuEXE/.rvm/gems/ruby-2.1.5/gems/rspec-support-3.1.2/lib /Users/PikachuEXE/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.1.7/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
in test environment

Some gem versions:

rails 4.1.8
rspec 3.1.0
rspec-core 3.1.7
rspec-rails 3.1.0

rake 10.4.2 doesn't support "rake -f <filename>"

ben-dev-d4a ~/code $ rake --version
rake, version 10.4.2
ben-dev-d4a ~/code $ rake -f scarecrow-rules/scripts/crow/Rakefile
/home/benmayne/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/test/unit.rb:49:in `process_args': invalid option: -f (OptionParser::InvalidOption)
        from /home/benmayne/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
        from /home/benmayne/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
        from /home/benmayne/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/test/unit.rb:21:in `run'
        from /home/benmayne/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
        from /home/benmayne/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
        from /home/benmayne/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
ben-dev-d4a ~/code $

Downgrading to 10.3.2 solves the problem. --rakefile has the same problem.

Rake 11.0.0 crashes with "cannot load such file -- rake/ext/fixnum"

Tried the latest rake on a Rails and Sinatra project and I'm getting this result

Traviss-MacBook-Air:railsbridge_docs tjgrathwell$ rake
/Users/tjgrathwell/.rvm/gems/ruby-2.2.0/gems/rake-11.0.0/lib/rake.rb:37:in `require': cannot load such file -- rake/ext/fixnum (LoadError)
    from /Users/tjgrathwell/.rvm/gems/ruby-2.2.0/gems/rake-11.0.0/lib/rake.rb:37:in `<top (required)>'
    from /Users/tjgrathwell/.rvm/gems/ruby-2.2.0/gems/rake-11.0.0/bin/rake:31:in `require'
    from /Users/tjgrathwell/.rvm/gems/ruby-2.2.0/gems/rake-11.0.0/bin/rake:31:in `<top (required)>'
    from /Users/tjgrathwell/.rvm/gems/ruby-2.2.0/bin/rake:23:in `load'
    from /Users/tjgrathwell/.rvm/gems/ruby-2.2.0/bin/rake:23:in `<main>'
    from /Users/tjgrathwell/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/tjgrathwell/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'

Rake won't run

I'm very new to ruby and programing in general, forgive my ignorance. I'm trying to do a simple debugging exercise and am encountering an error that I can't make heads or tails of. When I try and run rake in the directory I get an error message about locating rspec?

(in /Users/Sam/Documents/learn_ruby-master)
rake aborted!
Gem::LoadError: Could not find 'rspec' (~> 2) - did find: [rspec-3.4.0]
Checked in 'GEM_PATH=/Users/Sam/.gem/ruby/2.2.0:/Users/Sam/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0', execute `gem env` for more information
/Users/Sam/Documents/learn_ruby-master/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)
Samuels-MacBook-Air:00_hello Sam$ 

is there something I need to install or configure that I haven't?

Syntax error: Unexpected tSTRING_BEG

Hi guys,

I am not sure whether I am writing to the write place but one weird error has occurred. Below is the screenshot. I presume there might be something wrong with my rake? Currently I have the latest ruby and rails versions. And I even cannot check the rake -v because this error gets thrown any time I am trying to execute whatever rake blahblah command.

screen shot 2015-09-12 at 8 43 53 pm

Thank you in advance for help!

Failed tests in Ruby:ruby-head

There are several pull requests failing because of some tests in TestRakeApplicationOptionsfail in Ruby:ruby-head.
Seems that the tests assume functionality which is changed in current Ruby…
samples #64, #67 but there are more 😞

Strange issue where rake culls some tasks

So here's my task:

task complete: [:reset, :setup, :restore, 'db:clone:sanitize:complete', :delete, 'db:structure:dump', 'db:migrate']

Here's the task list of Rake::Application:0x007feac2229ae8:

   "db:clone:reset"=><Rake::Task db:clone:reset => [db:drop, db:create]>,
   "db:clone:setup"=><Rake::Task db:clone:setup => [db:warn]>,
   "db:clone:pull"=><Rake::Task db:clone:pull => [db:warn]>,
   "db:clone:restore"=><Rake::Task db:clone:restore => [pull]>,
   "db:clone:sanitize:users"=><Rake::Task db:clone:sanitize:users => [db:warn, environment]>,
   "db:clone:sanitize:designers"=><Rake::Task db:clone:sanitize:designers => [db:warn, environment]>,
   "db:clone:sanitize:admins"=><Rake::Task db:clone:sanitize:admins => [db:warn, environment]>,
   "db:clone:sanitize:complete"=><Rake::Task db:clone:sanitize:complete => [users, designers, admins]>,
   "db:clone:delete"=><Rake::Task db:clone:delete => []>,
   "db:clone:"=><Rake::Task db:clone: => []>,
   "db:clone:complete"=>
    <Rake::Task db:clone:complete => [reset, setup, restore, db:clone:sanitize:complete, delete, db:structure:dump, db:migrate]>,
   "db:migrations:push_old_residential_budgets_to_other"=>

Notice "db:clone:complete".

However, the output of bin/rake -T db:clone:

rake db:clone:delete              # Clean up the database dump directory
rake db:clone:pull                # Pull down the database from some url
rake db:clone:reset               # Rebuild the entire database
rake db:clone:restore             # Restore the database from a dump file
rake db:clone:sanitize:admins     # Sanitize all of the admins privacy fields
rake db:clone:sanitize:designers  # Sanitize all of the designers privacy fields
rake db:clone:sanitize:users      # Sanitize all users privacy fields
rake db:clone:setup               # Create a place for database dumps

This is not specific to this task, it seem to affect all custom tasks in lib/task that are only a set of steps.

rack: (1.6.4, 1.5.5)
ruby: 2.1.5p273
rails: 4.1.9

If this isn't a rack bug I'll shop around rails. :/

rake-standalone: an initiative for a standard rake distribution

Hello,
I do like rake quite a lot and I thank you for the effort spent on it. When trying to use it "professionally" (both at the companies where I've worked and in some open source projects) I've had to fight with "different behaviours" of rake caused by different versions installed around and/or different ruby versions.

Please note that my scope was far beyond Ruby projects: I want to use it in many situations, with other languages, as a substitute for crappy bash scripts or out-of-place GNU Makefiles.

So I've started this project to create a stable distribution for Rake with a stable API, which I dubbed Rake Standalone:

https://github.com/alanfranz/rake-standalone

I'd like to have some feedback from you: do you think it's interesting? Or do you feel it's not useful or straightly a bad idea?

no rake.gemspec in repository

Hello. I'd love to see a rake.gemspec added to the repository so that I can use:

gem 'rake', github: 'tmornini/rake', branch: 'allow_custom_test_loader'

in Bundler Gemfile. This would make it much easier to submit PRs such as #49.

As it stands, Bundler aborts as it does not believe that the repository is a gem.

Allow cleaning namespaces.

Rake::Task class has a clear() method for removing actions and prerequisites from task. Would it be possible to provide method like this for Rake::NameSpace to remove all tasks?

Also, there is no (at least I couldn't find any) method for searching for namespace like [](task_name) in Rake::Task. There is [](name) method in there, but it searches for task in namespace.

These two features could enable one to write:

Rake::NameSpace.get('namespace_name').clear

Where get is a bad excuse for a method name that returns namespace by name.

Rake not executing some tasks, gives "Invoke <task>s (first_time, not_needed)"

I posted a SO question about his issue here. Most of the background is there. Here's the gist:

I have a task called :run that takes one argument, :filter. Depending on what I pass as the argument, it will sometimes execute with the trace:

** Invoke run (first_time)
** Execute run

Other times it doesn't execute at all, giving the trace:

** Invoke runs (first_time, not_needed)

Notice that when it fails, the trace says runs and not run even though run is the task typed in the command.

This happens when I run the rakefile in some directories, but not others.

Using:

  • ruby 2.0.0p645 (2015-04-13) [i386-mingw32]
  • rake, version 10.4.2
  • Window 7

Support named task arguments

When creating tasks that take multiple optional arguments, specifying parameters becomes tedious.

When calling the following task

task :test, [:database, :table, :column, :host, :port, :user, :password] do
    # Something
end

and specifying only parameter user, I have to count its position and call rake as follows:

rake 'test[,,,,,testuser,]'

I suggest supporting a syntax using named parameters that makes calling these tasks easier and more readable, e.g.

rake 'test{user:testuser}'

I'd like to put this up for discussion, if it is acceptable, I'm willing to create a pull request.

method_missing on `params` object ignores arguments

When a task receives a params object whose inspect prints {:subdomain=>"support”}, calling params.fetch(:support) surprisingly returns nil. Clearly this is not a hash.

It looks like this is implemented via a method_missing which performs lookup. This implementation should throw if any arguments are passed, because if you're providing arguments you clearly didn't expect this to be a simple getter method.

Can't pass parameters to rake task

I have this task:

desc 'Tests input parameters'
task :params do |args|
  options = {}
  OptionParser.new(args) do |opts|
    opts.banner = "Usage: rake params [options]"
    opts.on("-F", "--file {file}", "A file", String) do |file|
      options[:file] = file
    end
  end.parse!
  puts options.inspect.green
end
rake params -- -Fmy_file.txt

In rake 10.3.x I receive:

{:file => "my_file.txt"}

In rake 10.4.x I receive:

{}

Why?

Rake tmp clear

Capybara creates html webpages in the tmp directory whenever save_and_open_page is used.

Should rake tmp:clear not clear these files out of the tmp/capybara folder when run or does the command only affect certain folders in tmp?

I asked if capybara should take care of these files but was advised that it wouldn't (teamcapybara/capybara#1583) so thought I'd check whether it is something rake should (or could) be doing.

Running tests with rake causes a hanging process.

After executing

rake test

the process does nothing and never returns. Very interesting is that this depends on the number of test scripts.

I did some debugging. Rake collects all the test and creates a string for launching another ruby process, which actually runs the test. After shorting the string, the specified tests are executed. If I check the started ruby process in the process explorer, it shows me only '�' as command line.

Environment:

Windows 7
Ruby 2.14 (RubyInstaller)
Rake 10.4.0, 10.1.0

Running the same tests on a Linux box or using JRuby on Windows is working.

Default default rake

Some rakefiles don't have default tasks. A good reason would be if each of the tasks does something destructive. For them, a great default task would be to list all available tasks. Best practice is documented at http://stackoverflow.com/a/11320444/300224

For DRY across the thousands of rakefiles out that use the above default, I recommend this be the default for all scripts without a default.

Presently, running rake where there is no default task produces a return status of 0 and this output:

rake aborted!
Don't know how to build task 'default'

(See full trace by running task with --trace)

Rake -n does not mark dependents for Execution

I have a Rakefile with these file tasks:

file "fileA" => %W[] do |t| sh %Q[echo contentA >#{t.name}] end
file "fileB" => %W[fileA] do |t| sh %Q[(cat fileA; echo transformationB) >#{t.name}] end
file "fileC" => %W[fileB] do |t| sh %Q[(cat fileB; echo transformationC) >#{t.name}] end

I perform this setup, where everything is built and then the first file in the chain (fileA) is updated:

$ rake fileC
echo contentA >fileA
(cat fileA; echo transformationB) >fileB
(cat fileB; echo transformationC) >fileC
$ touch fileA

And now rake -n tells me that only fileB needs to be updated...

$ rake -n fileC
** Invoke fileC (first_time, not_needed)
** Invoke fileB (first_time)
** Invoke fileA (first_time, not_needed)
** Execute (dry run) fileB

Even though it knows it must update both fileB and fileC:

$ rake fileC
(cat fileA; echo transformationB) >fileB
(cat fileB; echo transformationC) >fileC

I expected rake -n to tell me this:

$ rake -n fileC
[...]
** Execute (dry run) fileB
** Execute (dry run) fileC

The problem seems to stem from the fact that the internal function out_of_date? (in file_task.rb) does not take into account when a file should have updated its timestamp (but didn't, because this is a dry-run).

Failing test in Ruby 1.9.3

Howdy, running the test suite (as at tag v10.4.1) produces one erroring test:

  1) Error:
TestRakeTestTask#test_run_code_rake_default_gem:
NoMethodError: undefined method `default_specifications_dir' for Gem::Specification:Class
    /home/mpalmer/src/forks/rake/git/test/test_rake_test_task.rb:101:in `test_run_code_rake_default_gem'

Looks like default_specifications_dir wasn't included in stdlib until Ruby 2.0.

Please add a `last_comment` removal/deprecation warning for now

NoMethodError: undefined method 'last_comment' for #<Rake::Application:0x00000002b87b38> tells me nothing. Can you please add a Use last_description method warning for now? It can be removed in v12, but this was kind of a surprise and I don't think most people were expecting it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.