Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Bundle install with path and excluding a group fails when Gemfile.lock is present. #3981

Closed
paresharma opened this issue Sep 7, 2015 · 15 comments · Fixed by #4357
Closed

Comments

@paresharma
Copy link

Here is my Gemfile and Gemfile.lock:

#Gemfile
source 'https://rubygems.org'
gem 'json', github: 'flori/json', group: :development
#Gemfile.lock
GIT
  remote: git://github.com/flori/json.git
  revision: f7394adf3a50631b443135a95ec1bc9d8b8f32ab
  specs:
    json (1.8.3)

GEM
  remote: https://rubygems.org/
  specs:

PLATFORMS
  ruby

DEPENDENCIES
  json!

BUNDLED WITH
   1.10.6

The following command fails if we don't have the gem from Github already checkout in vendor/bundle.

bundle install --path=vendor/bundle --without development

It works if the Gemfile.lock is not present. Removing the Gemfile.lock is a work around.

Shouldn't this work or is there anything I'm doing wrong?

@TimMoore
Copy link
Contributor

TimMoore commented Sep 7, 2015

Fails how? Can you please paste the output?

@paresharma
Copy link
Author

Hi, here is the output. This only happens when we try to do a bundle install locally without a group that has gem from git.

bundle install --path=vendor/bundle --without development
git://github.com/flori/json.git (at master) is not yet checked out. Run `bundle install` first.
Bundler gave the error "git://github.com/flori/json.git (at master) is not yet checked out. Run `bundle install` first." while processing "/Users/pareshsharma/Workspace/xtra/test/Gemfile". Perhaps you forgot to run "bundle install"?

@agis
Copy link
Contributor

agis commented Sep 13, 2015

@paresharma I could reproduce the error following the steps you've described.

After some digging around, it seems that #resolve_if_need doesn't actually download the gem when it should. This happens because local is set to true:

# in lib/bundler/installer.rb #resolve_if_need
# ...
begin
  tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
  # `tmpdef.missing_specs` is empty
  true unless tmpdef.new_platform? || tmpdef.missing_specs.any?
rescue BundlerError
end
# ...

I'm not sure however if json in this case should appear as a missing spec, since --without should download but not install the gems.

@indirect Any insights?

@indirect
Copy link
Member

I think that missing_specs should have json in it if the gem is in the Bundle; the installer will skip installing the gem later if it's in a without group.

@RochesterinNYC
Copy link
Contributor

Verified that this has been fixed in v1.11.2.

$ bundle install --path=vendor/bundle --without development
Fetching git://github.com/flori/json.git
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using bundler 1.11.2
Bundle complete! 1 Gemfile dependency, 1 gem now installed.
Gems in the group development were not installed.
Bundled gems are installed into ./vendor/bundle.

@paresharma
Copy link
Author

@RochesterinNYC The issue still persists with v1.11.2. Please find below the trace for the same.

➜ ll
total 16
-rw-r--r--  1 paresharma  staff    84B Mar  5 22:10 Gemfile
-rw-r--r--  1 paresharma  staff   235B Mar  5 22:15 Gemfile.lock
drwxr-xr-x  3 paresharma  staff   102B Mar  5 22:12 vendor

➜ cat Gemfile
source 'https://rubygems.org'
gem 'json', github: 'flori/json', group: :development

➜ cat Gemfile.lock
GIT
  remote: git://github.com/flori/json.git
  revision: f7394adf3a50631b443135a95ec1bc9d8b8f32ab
  specs:
    json (1.8.3)

GEM
  remote: https://rubygems.org/
  specs:

PLATFORMS
  ruby

DEPENDENCIES
  json!

BUNDLED WITH
   1.11.2

➜ bundle --version
Bundler version 1.11.2

➜ bundle install --path=vendor/bundle --without development
git://github.com/flori/json.git (at master@f7394ad) is not yet checked out. Run `bundle install` first.

@RochesterinNYC RochesterinNYC reopened this Mar 5, 2016
@RochesterinNYC
Copy link
Contributor

Okay, apologies. The exact Gemfile.lock you had was necessary to reproduce this.

Quick question @paresharma @indirect, what is the intended/expected behavior here? That this would be essentially a no-op because of the --without development? Or something else?

Though, I will note that the behavior/error occurs with simply bundle install --path=vendor/bundle as well.

@asutoshpalai
Copy link
Contributor

@RochesterinNYC: Hi, I am interested in resolving this

@RochesterinNYC
Copy link
Contributor

@asutoshpalai sure, go ahead.

@indirect
Copy link
Member

indirect commented Mar 8, 2016

Running bundle install should check out git repos that are missing—it shouldn't be possible to get the "not checked out yet" error while running the install command. Theoretically, git repos should not be checked out if you also pass the --local option, but that is currently not implemented. This is definitely a bug.

@RochesterinNYC
Copy link
Contributor

@asutoshpalai please let me know if you intend on resolving this, as I already might have a fix.

@asutoshpalai
Copy link
Contributor

Yes, I am still interested in resolving this, but I see that there is a already pull request for a related issue.
Sorry for the delay, I was stuck in some inevitable circumstances. Should I still go ahead on this?

@RochesterinNYC
Copy link
Contributor

If you're referring to #4353, that is a pull request for something different than this exact issue (it's related to the second part of @indirect's above comment.

@asutoshpalai
Copy link
Contributor

Yes, indirect's comment made me think so, my bad. I had investigated the issue a bit and now I am writing a failing spec for this issue.

asutoshpalai added a commit to asutoshpalai/bundler that referenced this issue Mar 11, 2016
@asutoshpalai
Copy link
Contributor

bundle install --path=vendor/bundle fails because bundle install --path=vendor/bundle --without development is ran once and so it is added to the .bundle/config. Then running bundle install --path=vendor/bundle actually run without the group development. If you run it on a fresh reproduction of the issue, it runs fine.

asutoshpalai added a commit to asutoshpalai/bundler that referenced this issue Mar 11, 2016
homu added a commit that referenced this issue Mar 16, 2016
Checking out missing git repos (but not being installed) - Fixing #3981

Fixes #3981.

As far as I investigated the problem is, being in `without` group, it is not marked in missing_spec and so it is not resolved while resolving specs at https://github.com/bundler/bundler/blob/master/lib/bundler/installer.rb#L183
and https://github.com/bundler/bundler/blob/master/lib/bundler/installer.rb#L195
but it is in the definition's index at
https://github.com/bundler/bundler/blob/master/lib/bundler/definition.rb#L209
leading to
https://github.com/bundler/bundler/blob/master/lib/bundler/source/git.rb#L150
where it checks for the presence of the folder at
https://github.com/bundler/bundler/blob/master/lib/bundler/source/path.rb#L135

Possible solutions are :
- add it to the list of missing_specs
- check while building the index in Definition class and don't add it.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants