Culerity fails if JRuby is not in a standard path
Opened this issue · 18 comments
It would be nice to be able to specify the path where JRuby is located. I've installed JRuby using RVM, and because the path to JRuby is not in a standard location Culerity.run_server will fail. For some reason, saying rvm use jruby; which ruby
doesn't work so I don't know of a way of figuring out where JRuby is located programmatically in this case. Thus the need to specify the path manually.
Answering myself... On second thought, it's not so easy to get Culerity working at all if you're using a version of JRuby you've installed through RVM, because even if you add JRuby to your path (or make a symlink in /usr/local/bin) then Culerity will fail since it won't be able to find JRuby gems, since those are in a non-standard location too. It works fine if you install JRuby manually, although I'm not sure how. It must not look in GEM_HOME by default, or use a different variable or something. Anyway, I guess assuming that jruby is in the PATH is the best move here. The caveat is that if other developers are working on the same project I am and they want to write Culerity features too, they have to install JRuby the exact same way I did. And I wanted to avoid this. I suppose there isn't an alternative atm, though.
i have installed jruby by hand which as you said works without any problems. couldn't you just set the PATH and if required other environment variables to get this working?
Yeah I could have done this. I hate messing with paths though and telling other people they have to do that too so I was trying to avoid it. Now I know though, don't use RVM's JRuby with Culerity ;) So I guess you can close this.
well if you have any suggestion on how to improve this i wanna hear it
mcmire: one solution that may work for you is to embed JRuby into culerity itself. I've done this on a fork I created last month: http://github.com/fletcherm/culerity
The upside is that JRuby comes along with culerity and you don't need it installed system-wide. The downside is that the culerity distribution is quite a bit larger. Embedding jruby-complete takes about 11 megs. It has been worth the tradeoff for me.
Ah - now that's interesting, actually. If it were another project I'd say no way, but considering that Culerity is currently the only way (I know of) to run Javascript-centric Cucumber tests in a standard MRI environment, this makes sense to me... Oh and I see you're vendoring celerity too which means no need to do /path/to/jruby -S gem install celerity (which I doubt will work correctly anyway). Alex, how do you feel about this?
mcmire: woops, I forgot to mention that this is available on gemcutter as fletcherm-culerity. The code should be up to date wrt to mainline culerity.
rvm actually creates several environment variables that (MacPorts) JRuby will observe. This has the unpleasant side effect of causing (MacPort) JRuby to install gems into the gemdir of another ruby!
If you want to use rvm's JRuby instead of MacPorts, then I've documented an alternative approach here: http://gist.github.com/268216
In the Before
and After
hooks, I adjust various environment paths to point to the copy of JRuby managed by rvm.
It would seem less hacky if I could avoid hardcoding paths.
mchung: Okay, I figured it involved something like that, I wasn't sure what the correct paths should have been. As long as it works then it's better than embedding JRuby IMO. I know of a way to avoid hardcoding the paths, I think (thanks to our friends Dir.glob and ENV["HOME"]). I'll have to take a closer look at it.
mcmire: The path to rvm can be adjusted via rvm_path. See http://rvm.beginrescueend.com/rvmrc/
mcmire, I figured it out. Check out the gist.
i have linked your gist in the wiki. do you think this issue is solved or do you have any suggestions on how to include your fixes into culerity itself?
Thanks Alex,
Actually, I do:
- Add a generator template for this hooks.rb file in the culerity gem so that it may optionally be added during installation, i.e. ./script/generate culerity --rvmhooks. I'll fork and do this (as soon as possible).
Could someone else try this out and let me know how it goes. At the moment, I have this tested on a very tiny project that uses very little Prototype.
(It still weirds me out that I can adjust the environment paths at runtime.)
mchung: Hmm, it doesn't seem that your setup is working for me. Even with your hooks it seems that it can't find JRuby. My hunch is that when the jruby system call is done, it's not seeing the updated environment variables somehow. Then again, I have a different setup. My system Ruby is one I compiled/installed manually, which I'm using along with RVM JRuby. Also, I'm using MRI 1.8.6, not 1.8.7. Also, I'm not using Capybara (because this is for work and the app is only Rails 2.2, so no Rack support). I think later today I might try to replicate your setup exactly, in another project, and see if I can get it to work that way.
"My system Ruby is one I compiled/installed manually, which I'm using along with RVM JRuby."
That's where the first problem is. My hooks.rb uses rvm specific environment variables because it assumes you're running Ruby on rvm. It should be easy to workaround that though.
I'm a little late to this party, but I thought I'd throw in my experience as well. Based on mchung's work, I came up with a slightly more dynamic way of specifying the jruby to use. It's only a tab bit less "hackish", but it's still something of a hack.
This is all based on a custom runner script that I have to process a number of things before calling cucumber. Via a command line switch, I tell it which version of rvm ruby I want to use and optionally which rvm jruby. Those values get "passed" to culerity via ENV, and you can see what happens next. So far, this has worked out pretty well for me as I am able to easily do development on Snow Leopard's ruby and verify everything runs correctly on ree-1.8.6, which is what I currently have to deploy one project to.
The code in your gist here worked perfectly for me Phillip. Thanks for your work figuring this out.
i have linked your gist in the wiki. do you think this issue is solved or do you have any suggestions on how to include your fixes into culerity itself?
کتاب های آمازون
مکان های دیدنی ایران