Save myself from bundler
It always bothers me that bundler's user configuration has different semantics
than project configuration. By user configuration, I mean the file located at:
~/.bundle/config. By project configuration, I mean the file located at:
PROJECT_ROOT/.bundle/config.
(well, it also bothers me a lot that sometimes it's called bundler,
and sometimes it's called bundle)
The difference is that project configuration would respect ruby_scope (in
bundler's term), while user configuration would not. This troubles me a lot.
If it's the reversed way, then I guess I can accept the inconsistency, since
I can just forget about project configuration, and setup user configuration
once and for all.
The problem is that bundler won't respect ~/.gemrc, so it ignores my --user option:
gem: --user --env-shebang --no-rdoc --no-riIt would always try to install gems to the system. No please, don't ask me
to change
GEM_PATH or GEM_HOME, otherwise I would be messing up withother rubies as well (and ENV). I just want that simple
--user option....I guess I might be the only one who is using user gems. By user gems, I mean
I install all my gems into
~/.gem/ruby/1.9.1 and ~/.gem/jruby/1.9 and~/.gem/rbx/1.9. That's exactly what --user would do. I don't install gems inmy system, *at all*, and I don't use RVM, *at all*.
So I must have a config to tell bundler to install to the right place. This raises
another issue, I need it to respect
ruby_scope. But only project configurationwould respect
ruby_scope, not the one resides in ~/.bundle/config. If you'recopying project config to user config, or the other way around, you might be
installing to unexpected place.
I ended up with setting my
~/.bundle/config to point to /tmp because it justdidn't work at all, and whenever I restarted my computer, the wrongly installed
stuff would be cleaned up. Whenever I realize that it's installing to a wrong
place, then I would frustratedly copy my last working project config to the newly
created project. This is causing more troubles when `
rails new` would try torun `
bundle install`...... a chain of shits.I couldn't stand anymore, digging into the source, sending this pull request.
lib/bundler/settings.rb: Always respect Bundler.ruby_scope
Well, I am not too optimistic if they would merge it, since apparently the
inconsistency is designed for, not really a bug. I did see there are some
tests which would make sure this inconsistency won't break...
That's why my pull request didn't pass Travis' verification. I am not going
to fix it because they might not like the consistency I am looking for,
and I don't want to waste my time fixing something which would never
going to be merged. I would definitely be glad to fix it if they promise to
fix this inconsistency.
At last, I decided to save myself, by patching bundler on my own computers.
So here's the exact monkey patch. bundler/monkey.rb
Whenever I run `
bundle`, it would first try to load the monkey patch.This is enough for my Mac, but I need another patch for my Linux,
I am not sure why. Whenever someone does require 'bundler/setup',
it would also first grab the monkey first. This is needed for my Linux.
Then I set
RUBYOPT=-I~/.config/bundler in my ~/.bash_profile for my Linux.Perfect, now everything works as expected.
Oh, it's only perfect if I don't have to look into it again, in the future.
I am not very optimistic about this either.


0 retries:
Post a Comment
Note: Only a member of this blog may post a comment.