-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use bundler/setup instead of custom loading code #530
Use bundler/setup instead of custom loading code #530
Conversation
Adding "require 'bundler/setup'" to a file will add the bundled gems to the load path. This is a much safer way to load gems instead of using `gem <gemname>, <version>` where version is parsed from the Gemfile. Loading 'bundler/setup.rb' does the following things: 1. Cleans load path, whose one function is to removing system gems from the load path. 2. Loads the gem specs from Gemfile.lock 3. Sets up the following path variables: BUNDLE_BIN_PATH BUNDLE_GEMFILE: location of the Gemfile PATH: Appends the location of `bundle` executable for the current Ruby version to the PATH. RUBYOPT RUBYLIB 3. Activate the loaded Gem file specs. This is where the command would throw an exception if there's a conflict in the case where a different version of a particular gem in the Gemfile.lock has already been loaded. This makes the process more transparent. If there are any conflicts, an exception would be raised and this can be caught and the resulting backtrace can be handled properly.
Any pointers on how can this be tested are appreciated. I couldn't really figure that part out. (assuming this even works in general) |
I like this approach quite a bit, will give it a try locally and see how it works out! |
This is one of the failure situations: A project's Gemfile specifies method_source I tried to add some print statements inside the
|
Update TL;DR Even if The longer version The two things I had to do to really make it work:
To test, this is what I did:
Now, removing the To figure out the issue, this is what I did: Modified |
…icit Use bundler/setup instead of custom loading code
I'm happy enough with issues surrounding json and rake being mitigated by this to merge it. |
@latortuga Thanks for checking this out! |
This reverts commit c26469a, reversing changes made to d809774. The README currently advises running Zeus outside of bundler: https://github.com/burke/zeus/blob/810c8f49798d4f64b16894abd94beedbddb0b37f/README.md#installation I agree that running Zeus without bundler is probably a bad tradeoff in terms of stability but I don't think we can change this without breaking everyone's Zeus integrations: #570 I believe we should revert until we're prepared to re-introduce this with changes to the README, better error messaging to help people transition and possibly a major version bump.
Revert #530 (requires using Zeus with bundler)
I'm not sure if this has been discussed already. Using the
require 'bundle/setup'
directive made the gem activation errors a bit morepredictable for me during some preliminary runs. It's quite possible
that I might've missed something here.
Adding "require 'bundler/setup'" to a file will add the bundled gems to
the load path. This is a much safer way to load gems instead of using
gem <gemname>, <version>
where version is parsed from the Gemfile.Loading 'bundler/setup.rb' does the following things:
from the load path.
BUNDLE_BIN_PATH
BUNDLE_GEMFILE: location of the Gemfile
PATH: Appends the location of
bundle
executable for the currentRuby version to the PATH.
RUBYOPT
RUBYLIB
throw an exception if there's a conflict in the case where a
different version of a particular gem in the Gemfile.lock has already
been loaded.
This makes the process more transparent. After this change, the error
notifications would be split into two cases: 1. Before the connection
between Go daemon and the Ruby process gets established and 2. After the
connection gets setup.
In the case of 1, the error messages still won't show up in the UI and
dtruss
orstrace
is the only way to figure out the error. However,in the case of 2, any error in the loading would cause the zeus Go
process to throw an error (prompts turning red) and running any of the
commands would result in a backtrace.