# How to install patches?

**URL:** <https://www.ruby-forum.com/t/how-to-install-patches/64091>\
**Category:** Rails\
**Created:** [June 21, 2006, 11:32pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091 "2006-06-21T23:32:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [June 21, 2006, 11:32pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/1 "2006-06-21T23:32:17Z")

</div>

Hi,  
Can someone explain how do I install patches.  
Once I go to the page, I am not sure what to download and how to apply?

I am RoR newbie.

-Thanks  
Hari

---

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [March 4, 2009, 6:21pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/2 "2009-03-04T18:21:17Z")

</div>

Hari R. wrote:

> Can someone explain how do I install patches.

I canâ€™t believe that a straightforward, reasonable question like this  
went unanswered for 2 and a half years. Especially given how little info  
there is about applying or installing patches out there.

Anyway, this is how to install/apply patches once youâ€™ve got the .diff  
file\* downloaded. I donâ€™t know how to do it from repositories, Iâ€™m a  
newbie too sadly, but hopefully this will be useful to someone.

- note - often patch files are named .dif or .diff, but often they wonâ€™t  
have any file extension at all. They usually come double-zipped in  
.tar.gz despite only being one file.

First, unzip the patch file completely, and put it in the root directory  
of your app.

For the next step, you need a bash console â€“ the ones where there is a $  
before each input line. This is a unix thing, Linux and Macs come with  
them as standard - though I don’t know if they have the ‘patch’ binaries  
as standard, sorry.

If youâ€™re using Windows, install CygWin from [cygwin.com](http://cygwin.com). Cygwin doesnâ€™t  
come with the â€˜patchâ€™ binaries package as standard â€“ you need to add it  
during the setup process. Thereâ€™ll be a screen offering you a huge list  
of categories of packages. Hit the â€˜Viewâ€™ button to switch to an  
alphabetical list of all packages to find ‘patch’.

Once youâ€™ve got a bash shell with patch installed, open it, navigate to  
your appâ€™s root directory, then do a patch command to apply the patch.  
This will usually look like this:-

$ patch -p0 -i name\_of\_patch\_here

I say â€˜usuallyâ€™ because, to be honest, I donâ€™t know what -p0 or -i do,  
but it works for me. If that doesnâ€™t work as expected, on one site, I  
saw it written this way:-

$ patch -p0 \< name\_of\_patch\_here.patch

That should work. I hope this is useful to someone and saves you the  
hours it took me to find it all the hard way…

---

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [March 4, 2009, 7:42pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/3 "2009-03-04T19:42:58Z")

</div>

Try this:  
[http://afreshcup.com/2008/10/27/contributing-to-rails-step-by-step/](http://afreshcup.com/2008/10/27/contributing-to-rails-step-by-step/)

2009/3/4 Jeff S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [March 4, 2009, 6:41pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/4 "2009-03-04T18:41:49Z")

</div>

Alan Slater wrote:

> Hari R. wrote:

> > Can someone explain how do I install patches.

> I canâ€™t believe that a straightforward, reasonable question like this  
> went unanswered for 2 and a half years. Especially given how little info  
> there is about applying or installing patches out there.

Could you please provide a little information on how one submits patches  
for rails? I’ve gotten as far as git clone, but then everything goes to  
hell. (I can be more specific if anyone feels like throwing me a bone.)  
I’ve been trying to follow along with this screencast:

> **[\#113 Contributing to Rails with Git - RailsCasts](http://railscasts.com/episodes/113-contributing-to-rails-with-git)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

> This will usually look like this:-
> 
> $ patch -p0 -i name\_of\_patch\_here
> 
> I say â€˜usuallyâ€™ because, to be honest, I donâ€™t know what -p0 or -i do,  
> but it works for me.

-p is for stripping leading parts of the path, e.g. -p1 is used to turn  
absolute paths into relative paths. -p0 should be a no-op. -i means  
you’re going to pass the patch file as an argument, rather than letting  
the patch program read stdin. The above should be equivalent to:

$ patch \< name\_of\_patch\_here

---

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [March 4, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/5 "2009-03-04T21:18:02Z")

</div>

I think you need the mocha gem installed. Otherwise I am outside my  
knowledge base both with sqlite and mac.

2009/3/4 Jeff S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [March 4, 2009, 9:23pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/6 "2009-03-04T21:23:56Z")

</div>

Colin L. wrote:

> I think you need the mocha gem installed.

Well, holy crap! It’s at least getting past that initial error about  
“undefined method `\<=\>’”. Thanks!

> Otherwise I am outside my  
> knowledge base both with sqlite and mac.

FWIW, I tried mysql from MacPorts, and nothing worked with that, either.  
I’m hitting lots of little, time-consuming, irritating things; e.g.  
the tutorials all refer to mysql, but MacPorts actually installs it as  
mysql5.

---

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [March 4, 2009, 8:46pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/7 "2009-03-04T20:46:04Z")

</div>

Colin L. wrote:

> Try this:  
> [http://afreshcup.com/2008/10/27/contributing-to-rails-step-by-step/](http://afreshcup.com/2008/10/27/contributing-to-rails-step-by-step/)

Thanks, that looks promising. Unfortunately, rake self-test fails  
immediately. Here is the error message, with some path prefixes  
removed, and lines split for Usenet readability:

$ rake test\_sqlite3  
(in rails/activerecord)  
:0:Warning: Gem::manage\_gems is deprecated   
and will be removed on or after March 2009.  
/opt/local/bin/ruby -Ilib:test:test/connections/native\_sqlite3  
[lots of .rb paths elided]  
internal:gem\_prelude:249:in `push_gem_version_on_load_path':\ undefined method `\<=\>’ for nil:NilClass (NoMethodError)  
from internal:gem\_prelude:14:in `gem' from rails/activerecord/test/cases/helper.rb:8:in `\<top (required)\>’  
from rails/activerecord/test/cases/aaa\_create\_tables\_test.rb:2:  
in `require' from rails/activerecord/test/cases/aaa_create_tables_test.rb:2:\ in `\<top (required)\>’  
from rake-0.8.3/lib/rake/rake\_test\_loader.rb:5:in `load' from rake-0.8.3/lib/rake/rake_test_loader.rb:5:in `block in ’  
from rake-0.8.3/lib/rake/rake\_test\_loader.rb:5:in `each' from rake-0.8.3/lib/rake/rake_test_loader.rb:5:in `’  
rake aborted!  
Command failed with status (1):   
[/opt/local/bin/ruby -Ilib:test:test/connec…]  
(See full trace by running task with --trace)  
$

The relevant line (8) in helper.rb looks like this:

gem ‘mocha’, ‘\>= 0.9.5’

By the way, how does one “create” and empty sqlite3 database? I tried  
mysql, and it fought me, too. I think part of my problem is that I’m  
trying to come to grips with OS X (coming from other Unixen) at the same  
time I’m trying to learn Rails.

---

<div class="post-metadata">

**Author:** ![haries](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/4491bb/32.png) [@haries](https://www.ruby-forum.com/u/haries)\
**Post date:** [March 4, 2009, 10:58pm UTC](https://www.ruby-forum.com/t/how-to-install-patches/64091/8 "2009-03-04T22:58:55Z")

</div>

Jeff S. wrote:

> Colin L. wrote:
> 
> > I think you need the mocha gem installed.
> 
> Well, holy crap! It’s at least getting past that initial error

By the way, do you think this merits a bug report and/or patch?

I found the following similar-but-different ticket:  
[http://rails.lighthouseapp.com/projects/8994/tickets/186-activerecord-test-failures-when-mocha-is-not-installed](http://rails.lighthouseapp.com/projects/8994/tickets/186-activerecord-test-failures-when-mocha-is-not-installed)
