Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bundle update with packaged gem from git repo does not work #1970

Closed
bobbus opened this Issue · 14 comments

3 participants

@bobbus

I just tried the new feature of bundle pack with the --all option : it is working fine, make it easily possible to package a private gem for heroku deployment.
@josevalim Thanks a lot fot this feature :)

Actually, the bundle update command used on the gem coming from the git repo, does not update the gem.
Notice that if you delete the gem source in vendor/cache and run bundle update for this gem, it will update the code in vendor/cache but it won't update the directory name where the gem is packaged to reflect the new state : the directory name should be the name of the git repo + the last commit hash. This result in a working stack but I believe it is not wanted . Also, if you run bundle install after, it will create the proper directory (then you can remove the old one).

This is related to #67, and I do not forget to cc @hone ;-)

@josevalim

Thanks @bobbus for the report.

When you do: bundle pack && bundle update, does it update the gems under vendor/cache?

If so, it basically means bundler keeps a configuration somewhere that the gems are being current packed and bundler is not keeping the --all information, so it is packing just part of it.

@josevalim

Ping.

@josevalim josevalim was assigned
@josevalim

@bobbus so i have tried to reproduce this but I can't find the issue. When you package a git repository and you had a previously packaged gem, indeed the gem is kept (the default bundler behavior is indeed to keep the previously packaged stuff). Calling bundle update (with a git package) will update the packaged git repository, but the gem is kept intact, which is expected. What am I missing?

@bobbus

@josevalim , you are right, bundle update is working properly. The only thing there is with this command it's it does not remove the old version packaged but it may be voluntary (?).
Also bundle update GEM_NAME_FROM_GIT looks like it is not working as it does not update the gem from the corresponding git repo.
Did I miss something ?

@hone
Owner

@bobbus does it remove it when you run bundle clean?

@bobbus

I think bundle clean is used to clean the installed gem not the ones packaged in vendor/cache. Isn't it ?

@bobbus

@josevalim , what do you mean by "the gem is kept intact" ?

@bobbus

I can reproduce the issue by removing the gem in the Gemfile and run bundle install : for a gem which came from a git repo, the cached gem is not remove.

@bobbus

I got another failing scenario : when gems are installed with a path option (ex: bundle install --path vendor/bundle) the bundle update command does not work properly with gem from git repo : it updates the Gemfile.lock to the last commit available but do not update the packaged gem.

@josevalim

I think there is some confusion because the word "gem" has a very broad meaning. So let's try to iron these things out:

The only thing there is with this command it's it does not remove the old version packaged but it may be voluntary (?).

This is intentional. Bundler just adds new gems to the package, it never removes them.

Also bundle update GEM_NAME_FROM_GIT looks like it is not working as it does not update the gem from the corresponding git repo.

Here is the gem ambiguity kicking in. In order to make this clear, let's also include the gem source (rubygems, path or git source in bundler parlance). That said, if you have gem from a rubygem source and then moved to a gem (of the same name) using git source, bundler will no longer touch the packaged gem from a rubygem source. On the other hand, if you mean that when bundle update GEM_FROM_GIT, it updates the git repository checkout but it does not update the packaged git checkout, yes, this is a bug. Is this what you mean?

I can reproduce the issue by removing the gem in the Gemfile and run bundle install : for a gem which came from a git repo, the cached gem is not remove.

Yes, bundler never removes stuff from the cache.

@bobbus

I can reproduce the issue by removing the gem in the Gemfile and run bundle install : for a gem which came from a git repo, the cached gem is not remove.

Yes, bundler never removes stuff from the cache.

I believe this is not true because the gem is deleted from vendor/cache when it's a gem from a rubygem source. The command ends up with Removing outdated .gem files from vendor/cache.

Also bundle update GEM_NAME_FROM_GIT looks like it is not working as it does not update the gem from the corresponding git repo.

Here is the gem ambiguity kicking in. In order to make this clear, let's also include the gem source (rubygems, path or git source in bundler parlance). That said, if you have gem from a rubygem source and then moved to a gem (of the same name) using git source, bundler will no longer touch the packaged gem from a rubygem source. On the other hand, if you mean that when bundle update GEM_FROM_GIT, it updates the git repository checkout but it does not update the packaged git checkout, yes, this is a bug. Is this what you mean?

So yes there is this bug, in fact, it does not depend if you are using bunde update or bundle update GEM_FROM_GIT command, it happen when you have installed gem with a --path option (as I described above). Sorry for the confusion, I missed it at first time.

I hope this would be clear and you would be able to reproduce it. Let me know if I can help, I tried to look at the Bundler code but it's quite difficult for me to look into.

@josevalim

Ok, thanks @bobbus, I will take a look at this soon. Meanwhile, could you please try to add some test cases to Bundler? Feel free to open different pull requests for each set of tests.

Here are tests for vendor/cache:

https://github.com/carlhuda/bundler/blob/master/spec/cache/git_spec.rb

About the bundle update issue, I believe it also concerns bundle install (since bundle install also updates the git repository) and you can find tests for this here:

https://github.com/carlhuda/bundler/blob/master/spec/install/git_spec.rb

I believe you will find writing a test case much easier than digesting the source code. :) Thanks!

@bobbus

Thanks @josevalim . Effectively, tests are much easier to understand than the source code. Will try to write some soon.

@josevalim

Thanks @bobbus. I am closing this in favor of the two new issues.

@josevalim josevalim closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.