Save myself from bundler (2)
updated 2012-09-20 22:38 Add this on top of Rakefile to fix it:
how Bundler's regular expression is matching against. Yeah, broken,
see the source.
*
I didn't realize that I would write another post for this...
The last post is at:
2192. 09-12 Save myself from bundler
So now the problem is that the patch doesn't work for running
`
run tests separately, and Bundler would hack into
make my patch broken.
This is why running the command to run the test would work,
but run the command via `
This is so hacky.
In short, if you run `
be expected, but if you run that command in a Ruby process which
loaded Bundler, then
As you can see in the source, it would try to prepend the bundler it is using,
and Ruby would inherit the ENV in a subprocess. BOOM, then it's wrong.
Actually I think I got trapped by this before too. Consider this. You're in a project
which is using a Gemfile, and then in this project, you would spawn a subprocess
to run another project, using different Gemfile, or not using Bundler at all. It's
simply wrong, and it's very hard to fix this without monkey patching Bundler.
I really feel Rails is hacky, and Bundler is hacky, and most of thing invented for
Rails are also hacky.
If you want to use Bundler,
hacky behaviour. This is so broken, and I don't think they are going to fix this.
ENV['RUBYOPT'] = "#{ENV['RUBYOPT']} -rbundler/setup"
You can't use -r bundler/setup
but only -rbundler/setup
because that'show Bundler's regular expression is matching against. Yeah, broken,
see the source.
*
I didn't realize that I would write another post for this...
The last post is at:
2192. 09-12 Save myself from bundler
So now the problem is that the patch doesn't work for running
`
rake test
` in Rails, because Rails would spawn a subprocess torun tests separately, and Bundler would hack into
RUBYOPT
tomake my patch broken.
This is why running the command to run the test would work,
but run the command via `
rake test
` won't work.This is so hacky.
In short, if you run `
ruby -e "p ENV['RUBYOPT']"
` everything wouldbe expected, but if you run that command in a Ruby process which
loaded Bundler, then
ENV['RUBYOPT']
would be ended up with:"-I~/.gem/ruby/1.9.1/gems/bundler-1.2.1/lib -rbundler/setup -I~/.config/bundler"
As you can see in the source, it would try to prepend the bundler it is using,
and Ruby would inherit the ENV in a subprocess. BOOM, then it's wrong.
Actually I think I got trapped by this before too. Consider this. You're in a project
which is using a Gemfile, and then in this project, you would spawn a subprocess
to run another project, using different Gemfile, or not using Bundler at all. It's
simply wrong, and it's very hard to fix this without monkey patching Bundler.
I really feel Rails is hacky, and Bundler is hacky, and most of thing invented for
Rails are also hacky.
If you want to use Bundler,
require 'bundler/setup'
yourself. Don't rely on thishacky behaviour. This is so broken, and I don't think they are going to fix this.
0 retries:
Post a Comment
Note: Only a member of this blog may post a comment.