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

Vendored gems require bundle install to be discovered #6683

Closed
volkanunsal opened this issue Sep 1, 2018 · 8 comments
Closed

Vendored gems require bundle install to be discovered #6683

volkanunsal opened this issue Sep 1, 2018 · 8 comments

Comments

@volkanunsal
Copy link

I'm trying to run a Docker container using gems from vendor/bundle, but the first time I use a gem such as rake bundler complains that it cannot find the library. I need to run bundle install again and see the Using gem XYZ fly by on my terminal before these libraries become discoverable by bundler.

Just to be sure, I have BUNDLE_PATH set in my environment to /app/vendor/bundle and I have also tried modifying ~/.bundle/config myself to add BUNDLE_PATH, but nothing worked.

Is there something I'm missing here?

@indirect
Copy link
Member

indirect commented Sep 1, 2018

Bundler definitely does not support using gems without having ever run bundle install before. If you feel like this is a bug, can you please provide enough information for us to reproduce it?

@volkanunsal
Copy link
Author

Sure, I can produce a Docker container this weekend. But I didn't realize this behavior was by design. I don't know much about how bundler works internally, so forgive me if this sounds ignorant. Why is bundle install necessary if there is already a BUNDLE_PATH in the environment that would tell bundler where to find the installed gems?

@indirect
Copy link
Member

indirect commented Sep 1, 2018

the first possibility off the top of my head is compiled gems, but the overall situation of “these files need to be installed in a specific way for this exact machine” is the entire reason why we only support using gems after running bundle installl. gems are not always files you can copy to a new machine and use.

@volkanunsal
Copy link
Author

I can understand that ensuring gems are suitable for the machine is a good rationale, but in this case the gems were built in the same Docker container where they will be used, so it shouldn't be necessary to run bundle install again.

Here is the repo where I tried to reproduce this issue.

https://github.com/volkanunsal/bundler_start_up

@deivid-rodriguez
Copy link
Member

deivid-rodriguez commented Sep 2, 2018

Thanks @volkanunsal! I was 100% sure I had seen this recently, so I decided to investigate since you provided a reproduction! 😃

I confirmed the issue, and that #6628 fixes it. So my plan would be to include that PR in the 1.16.5 milestone, and then you can fix the issue by configuring bundle config global_path_appends_ruby_scope true.

I think the fact that PR was not backported is unintentional, as per my comment in #6672 (comment).

@deivid-rodriguez
Copy link
Member

To further try to explain what the issue is about.

In bundler 1, when you have BUNDLE_PATH set globally, bundler won't consider those ruby/2.3.0 subfolders in your gems folder. But when you don't, it considers them. In your case, you probably run bundle install when BUNDLE_PATH was not yet set, so those subfolders were generated. But when you then invoke bundler, BUNDLE_PATH is set, so those subfolders are not considered, and the gems are not found.

@colby-swandale
Copy link
Member

It seems that this issue has been answered. Closing.

@deivid-rodriguez
Copy link
Member

Yeah, the relevant PR was marked for backporting (to 1.17.0 in the end), so this should get fixed once we released that version!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants