How to override gem dependency?

1,401 views
Skip to first unread message

Ewen

unread,
Nov 7, 2011, 6:17:15 AM11/7/11
to Spree
I'd like to change spree's papaerclip gem dependency but don't know
how. I tried overriding spree_core.gemspec but bundle is still
requiring the normal gem version. I need to be using paperclip 2.4.5
rather than 2.3.8.

How can I override gem dependencies?

Alexander Negoda

unread,
Nov 7, 2011, 6:31:51 AM11/7/11
to spree...@googlegroups.com
If you do this, you get a version conflict.
Take a fork, change the paperclip version and send pull request to spree core repo.(Do not forget to test the efficiency)

Ewen

unread,
Nov 7, 2011, 7:10:08 AM11/7/11
to Spree
I hoped that by overriding spree_core.gemspec I could make spree_core
require the same version of paperclip as I require and avoid a version
conflict. Are you saying the 2 spree_core.gemspec's conflict with
each other rather than the new one overriding the original? Is
forking spree_core the only way to get spree_core to require a
different version of paperclip?

On Nov 7, 11:31 am, Alexander Negoda <alexander.neg...@gmail.com>
wrote:

Alexander Negoda

unread,
Nov 7, 2011, 7:33:59 AM11/7/11
to spree...@googlegroups.com

I hoped that by overriding spree_core.gemspec I could make spree_core
require the same version of paperclip as I require and avoid a version
conflict.  Are you saying the 2 spree_core.gemspec's conflict with
each other rather than the new one overriding the original?  Is
forking spree_core the only way to get spree_core to require a
different version of paperclip?


spree_core.gemspec can not be overridden ;)
Look at it closely and you'll understand why you can not override:

You can add to their line Gemfile:
 gem 'paperclip', 'your version'
but it would conflict with the spree_core version

So the only way is to change the version of the paperclip in the spree_core. How can it do, I wrote in a previous post.

Ewen

unread,
Nov 7, 2011, 9:12:12 AM11/7/11
to Spree
Thanks.

I've not forked before and not sure I have time to learn how so might
look at patching the problem area of paperclip instead. Or I might
just have a cup of tea ;)

On Nov 7, 12:33 pm, Alexander Negoda <alexander.neg...@gmail.com>
wrote:

Ryan Bigg

unread,
Nov 9, 2011, 7:59:07 PM11/9/11
to spree...@googlegroups.com
Ewen: Forking the spree-core repository is a little convoluted at the moment, but if you know the steps it's very easy to use a slightly modified version of any facet of Spree.

The first thing you'll need to do is clone the Spree repository to your computer:

git clone git://github.com/spree/spree

This will clone it into a directory called "spree" in the current working directory (i.e. wherever it was where you ran the command). Next, you'll need to copy out the part of spree that you want, in this case "core" and move it into a new directory outside of this repository.

Once you've done that, you can make the modifications you need to this core part of spree. After that, you can then 

1. You can copy this directory into your application, placing it at a location such as "vendor/gems/spree_core". Then you would need to change the line in your application's Gemfile that references "spree_core" from something like this:

gem 'spree_core', '<version>'

To something different, like this:

gem 'spree_core', :path => "vendor/gems/spree_core"

This will then tell your application to use the modified spree_core instead of the original.

----

I will see about relaxing the paperclip dependency today so that in future versions you won't run into this issue.

Thanks!
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree...@googlegroups.com.
To unsubscribe from this group, send email to spree-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Dwayne Henderson

unread,
Nov 10, 2011, 8:06:07 AM11/10/11
to spree...@googlegroups.com
Thank you for this excellent workaround.

A tiny problem though after replacing gem "spree" with gem "spree_core", :path => "vendor/gems/spree_core":

$ bundle install
/cygdrive/c/Users/Anonymous/Desktop/spree/vendor/gems/spree_core/spree_core.gemspec:2:in `read': No such file or directory:
/cygdrive/c/Users/Anonymous/Desktop/spree/vendor/gems/SPREE_VERSION (Errno::ENOENT)

Any ideas?

--Dwayne

Dwayne Henderson

unread,
Nov 10, 2011, 10:03:25 AM11/10/11
to spree...@googlegroups.com
I was later told by Trung Lê:

On that line 2, spree_core try to looks for SPREE_VERSION file which is located in the root of spree tree.
Copy SPREE_VERSION to vendor/gems.

Thanks man.

--Dwayne

Ewen

unread,
Nov 11, 2011, 7:34:47 AM11/11/11
to Spree
Ryan,
Thanks for the detailed steps. I'll give that a go.
-Ewen

On Nov 10, 12:59 am, Ryan Bigg <m...@ryanbigg.com> wrote:
>  Ewen: Forking the spree-core repository is a little convoluted at the moment, but if you know the steps it's very easy to use a slightly modified version of any facet of Spree.
>
> The first thing you'll need to do is clone the Spree repository to your computer:
>
> git clone git://github.com/spree/spree
>
> This will clone it into a directory called "spree" in the current working directory (i.e. wherever it was where you ran the command). Next, you'll need to copy out the part of spree that you want, in this case "core" and move it into a new directory outside of this repository.
>
> Once you've done that, you can make the modifications you need to this core part of spree. After that, you can then
>
> 1. You can copy this directory into your application, placing it at a location such as "vendor/gems/spree_core". Then you would need to change the line in your application's Gemfile that references "spree_core" from something like this:
>
> gem 'spree_core', '<version>'
>
> To something different, like this:
>
> gem 'spree_core', :path => "vendor/gems/spree_core"
>
> This will then tell your application to use the modified spree_core instead of the original.
>
> ----
>
> I will see about relaxing the paperclip dependency today so that in future versions you won't run into this issue.
>
> Thanks!
>
>
>
>
>
>
>
> On Tuesday, 8 November 2011 at 1:12 AM, Ewen wrote:
> > Thanks.
>
> > I've not forked before and not sure I have time to learn how so might
> > look at patching the problem area of paperclip instead. Or I might
> > just have a cup of tea ;)
>
> > On Nov 7, 12:33 pm, Alexander Negoda <alexander.neg...@gmail.com (http://gmail.com)>
> > wrote:
> > > > I hoped that by overriding spree_core.gemspec I could make spree_core
> > > > require the same version of paperclip as I require and avoid a version
> > > > conflict.  Are you saying the 2 spree_core.gemspec's conflict with
> > > > each other rather than the new one overriding the original?  Is
> > > > forking spree_core the only way to get spree_core to require a
> > > > different version of paperclip?
>
> > > spree_core.gemspec can not be overridden ;)
> > > Look at it closely and you'll understand why you can not override:https://github.com/spree/spree/blob/master/core/spree_core.gemspec
>
> > > You can add to their line Gemfile:
> > >  gem 'paperclip', 'your version'
> > > but it would conflict with the spree_core version
>
> > > So the only way is to change the version of the paperclip in the
> > > spree_core. How can it do, I wrote in a previous post.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Spree" group.
> > To post to this group, send email to spree...@googlegroups.com (mailto:spree...@googlegroups.com).
> > To unsubscribe from this group, send email to spree-user+...@googlegroups.com (mailto:spree-user+...@googlegroups.com).
Reply all
Reply to author
Forward
0 new messages