How to run arbitrary ruby code using Ruby SDK configured for project


I am trying to create a RubyMine plugin that will allow some abritrary ruby code to be entered into an inut field and then executed.

I have searched the forums and have found some pointers to running ruby from within my plugin however they all seem to require and instanvce of com.intellij.openapi.projectRoots.Sdk nad I can't work out how to get the instance being used by the project.

I am not sure if I fully understand how to access the exact ruby installation/version that the project uses.

I have multiple rubies installed and when I try to call out to the command line using the project base dir as the working directory I get a different version to the version my projec tis configred to use.

I also don't know that calling out to the command line using Runtime.getRuntime().exec() is the best way to do this for a plugin.

So basically my question is this.

What is the recommended way, or your suggestion for the optimal way, to execute some abritrary code (say from a user's selection).

I am a little lost here so any suggestions or questions are more than welcome.


Please sign in to leave a comment.