Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Culerity fails if JRuby is not in a standard path #13

Open
mcmire opened this issue Dec 22, 2009 · 18 comments
Open

Culerity fails if JRuby is not in a standard path #13

mcmire opened this issue Dec 22, 2009 · 18 comments

Comments

@mcmire
Copy link

mcmire commented Dec 22, 2009

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.

@mcmire
Copy link
Author

mcmire commented Dec 23, 2009

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.

@langalex
Copy link
Owner

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?

@mcmire
Copy link
Author

mcmire commented Dec 23, 2009

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.

@langalex
Copy link
Owner

well if you have any suggestion on how to improve this i wanna hear it

@fletcherm
Copy link

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.

@mcmire
Copy link
Author

mcmire commented Dec 28, 2009

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?

@fletcherm
Copy link

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.

@mchung
Copy link

mchung commented Jan 4, 2010

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.

@mcmire
Copy link
Author

mcmire commented Jan 4, 2010

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.

@mchung
Copy link

mchung commented Jan 4, 2010

mcmire: The path to rvm can be adjusted via rvm_path. See http://rvm.beginrescueend.com/rvmrc/

@mchung
Copy link

mchung commented Jan 4, 2010

mcmire, I figured it out. Check out the gist.

@langalex
Copy link
Owner

langalex commented Jan 4, 2010

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?

@mchung
Copy link

mchung commented Jan 4, 2010

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.)

@mcmire
Copy link
Author

mcmire commented Jan 5, 2010

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.

@mchung
Copy link

mchung commented Jan 6, 2010

"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.

@phillipkoebbe
Copy link

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.

http://gist.github.com/322136

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.

@jasonroelofs
Copy link

The code in your gist here worked perfectly for me Phillip. Thanks for your work figuring this out.

@filesoo
Copy link

filesoo commented Nov 1, 2017

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?
کتاب های آمازون
مکان های دیدنی ایران

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

7 participants