# How to run a rake task from plugin's install.rb?

**URL:** <https://www.ruby-forum.com/t/how-to-run-a-rake-task-from-plugins-install-rb/117885>\
**Category:** Rails\
**Created:** [October 22, 2007, 4:41am UTC](https://www.ruby-forum.com/t/how-to-run-a-rake-task-from-plugins-install-rb/117885 "2007-10-22T04:41:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_JSBott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@Christopher\_JSBott](https://www.ruby-forum.com/u/Christopher_JSBott)\
**Post date:** [October 22, 2007, 4:41am UTC](https://www.ruby-forum.com/t/how-to-run-a-rake-task-from-plugins-install-rb/117885/1 "2007-10-22T04:41:04Z")

</div>

Hello,  
I wrote a plugin that adds some rake tasks. Upon installation of my  
plugin, I would like one of these rake tasks to be run. How do I do  
that in install.rb?

Thank you.

---

<div class="post-metadata">

**Author:** ![Christopher\_JSBott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@Christopher\_JSBott](https://www.ruby-forum.com/u/Christopher_JSBott)\
**Post date:** [October 22, 2007, 9:46am UTC](https://www.ruby-forum.com/t/how-to-run-a-rake-task-from-plugins-install-rb/117885/2 "2007-10-22T09:46:50Z")

</div>

On 10/21/07, Christopher J. Bottaro [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello,

Hello.

> I wrote a plugin that adds some rake tasks. Upon installation of my  
> plugin, I would like one of these rake tasks to be run. How do I do  
> that in install.rb?

Rake::Task[‘task:name’].invoke

–  
Chris W.  
[http://errfree.com](http://errfree.com) // [http://errtheblog.com](http://errtheblog.com)

---

<div class="post-metadata">

**Author:** ![Christopher\_JSBott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@Christopher\_JSBott](https://www.ruby-forum.com/u/Christopher_JSBott)\
**Post date:** [October 22, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/how-to-run-a-rake-task-from-plugins-install-rb/117885/3 "2007-10-22T17:51:53Z")

</div>

On Oct 22, 2:46 am, “Chris W.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Rake::Task[‘task:name’].invoke

I tried that and then ‘script/plugin install’ wouldn’t install it  
cleanly anymore.

When a plugin is installed, how/when is the install.rb file invoked?  
I mean, in that file, can I count on the Rails environment already  
being loaded?

Also, how do I test that file? I can’t simply say “ruby install.rb”  
unless I load all the environment stuff myself in that file.

Thanks for the help.
