0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Rakeコマンドとは

Last updated at Posted at 2024-12-05

rakeコマンドはmakeコマンド風のタスクを実行するためのタスクランナーで、実行する処理をRakeタスクと呼びます。主にリリース作業などの提携処理をRakeタスクとして定義します。
rakeコマンドではタスクの実行の他に現在実行可能なRakeタスクによりDBの管理を行ったり独自のRakeタスクを作成する場合があるため、簡単な使い方は覚えておきましょう。

...
現在のrailsではRakeタスクもrailsコマンドから実行できるようになったため直接rakeコマンドを使う頻度は少なくなりました。

RakeはRubyで作られているビルドツールです。Mac/Linux系の環境で昔からよく使われているビルドツールにMakeがありますが、RakeはそのRuby版だと言えます。ただし、もともとはビルドツールとして開発されたRakeですが、実際にはビルドに限らず、「何かしらのまとまった処理(=タスク)」を簡単に実行するためのツールとして使われたことも多いです。

Rakeコマンドで実行する

hello.rb -> Rakefile
task :hello_world do
        puts 'Hello, world'
end

rakefile, Rakefile, rakefile.rb, Rakefile.rbを探します

***********@****** % vim hello.rb
***********@******  % rake hello.rb
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

(See full trace by running task with --trace)
***********@******  % mv hello.rb Rakefile
***********@******  % ls
Rakefile	
***********@******  % rake hello_world
Hello, world
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?