Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question

Set up the Ruby environment with RVM or rbenv in Mac

asked 2015-06-15 17:26:27 -0600

updated 2015-07-24 16:39:50 -0600

Hello, I'm new to Ruby and OpenStudio measure development. I have a question upon how to set up the environment of OpenStudio library for Ruby in Mac.

Currently I'm running Ruby through rvm(Ruby Version Manager) which is a stand alone ruby directory so that I won't mess up with the System Ruby. Here's what I did: First I ran gem install openstudio to get the library installed. After that I ran require "openstudio" in the IRB, the error message prints:

LoadError: cannot load such file -- openstudioutilitiescore

My ruby version in the rvm is 2.0.0p643 and OpenStudio v. 1.7.5.

Any help would be appreciated!


Thanks David.

Here is what I did after:

I created the openstudio.rb file with the content:

require '/Applications/OpenStudio 1.7.5/Ruby/openstudio.rb'

And then saved it to:


Then I uninstalled the openstudio package (which I install with gem earlier)

I tried to run require "openstudio" again in the irb.

The reports prints:

-- Crash Report log information -------------------------------------------- See Crash Report log file under the one of following: * ~/Library/Logs/CrashReporter * /Library/Logs/CrashReporter * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports the more detail of.

-- Control frame information ----------------------------------------------- c:0027 p:-17572663487022 s:0124 e:000123 TOP [FINISH] c:0026 p:---- s:0122 e:000121 CFUNC :require c:0025 p:0113 s:0118 e:000117 METHOD /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/siteruby/2.0.0/rubygems/coreext/kernelrequire.rb:54 c:0024 p:0476 s:0108 e:000107 TOP /Applications/OpenStudio 1.7.5/Ruby/openstudio.rb:86 [FINISH] c:0023 p:---- s:0102 e:000101 CFUNC :require c:0022 p:0113 s:0098 e:000097 METHOD /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/siteruby/2.0.0/rubygems/coreext/kernelrequire.rb:54 c:0021 p:0007 s:0088 e:000087 TOP /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/siteruby/openstudio.rb:1 [FINISH] c:0020 p:---- s:0086 e:000085 CFUNC :require c:0019 p:0113 s:0082 e:000081 METHOD /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/siteruby/2.0.0/rubygems/coreext/kernelrequire.rb:54 c:0018 p:0007 s:0072 e:000071 EVAL (irb):1 [FINISH] c:0017 p:---- s:0070 e:000069 CFUNC :eval c:0016 p:0024 s:0063 e:000062 METHOD /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/irb/workspace.rb:86 c:0015 p:0025 s:0056 e:000054 METHOD /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/irb/context.rb:380 c:0014 p:0022 s:0050 e:000049 BLOCK /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/irb.rb:492 c:0013 p:0040 s:0042 e:000041 METHOD /Users/YJ/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/irb.rb:624 c:0012 p:0009 s:0037 e:000036 BLOCK /Users ...
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-18 10:26:32 -0600

long gravatar image

I think the issue is around the lack of the Ruby shared-libraries when using RVM (or rbenv).

For RVM, when you install the ruby, make sure to pass in the config flag for 'enable-shared'

rvm install 2.0.0 -C --enable-shared

If you use rbenv, then you need to export the environment variable

RUBY_CONFIGURE_OPTS=--enable-shared rbenv install 2.0.0-p353

You should then be able to do:

irb -I <path-to-openstudio.rb>

e.g. irb -I /Application/OpenStudio\ 1.7.5/Ruby/

I prefer to set an environment variable that points to my version of OpenStudio. In my .bash_profile, I add:

export RUBYLIB="/Applications/OpenStudio 1.7.5/Ruby"

edit flag offensive delete link more


Thanks Nick, what does the --enable-shared do?

macumber gravatar image macumber  ( 2015-06-18 11:59:29 -0600 )edit

That solves the problem. Thanks Nick!

yiyuan-jia gravatar image yiyuan-jia  ( 2015-06-18 13:37:05 -0600 )edit

It builds the shared libraries for Ruby which are needed for linking by OpenStudio. For Linux it builds the and for Mac the libruby.dylib.

long gravatar image long  ( 2015-06-18 15:06:57 -0600 )edit

answered 2015-06-16 11:23:26 -0600

updated 2015-06-16 11:26:57 -0600

If you want to use OpenStudio's ruby API outside of our GUI's you need to tell your system ruby where to find OpenStudio.

Create a file with this content.

require 'C:\Program Files\OpenStudio 1.7.0\Ruby\openstudio.rb'

Place it in your system ruby's site folder at a path similar to this.


Also, the openstudio gem isn't something you should typically use. You just need OpenStudio installed, and optionally ruby (you can use your system ruby, or you can use OpenStudio's installed ruby).

Update: Just found this described in more detail in the measure testing section of our measure writing guide.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer


Question Tools

1 follower


Asked: 2015-06-15 17:26:27 -0600

Seen: 529 times

Last updated: Jul 24 '15