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

Setting up Ruby Environment for Measures in Win 10

asked 2023-10-17 00:58:19 -0600

Redline's avatar

updated 2023-10-17 07:32:20 -0600

Looking at the OpenStudio compatibility matrix I have Ruby 2.7 installed locally. ( which is the correct version for my install) Currently using 3.5.1 (SDK) and 1.5 of the OS Application.

A Windows command prompt successfully can run any basic .rb script and I have some system variables set-up . I Have RUBYLIB that points to the openstudio.rb file located in D:\openstudioapplication-1.5.0\Ruby\openstudio.rb.

I am initially trying to run ruby test scripts from some of the pre-existing scripts. If I Run Ruby from a cmd prompt and go to this folder

C:\Users\xxx\OpenStudio\Measures\FindAndReplaceInAllThermalZoneNames\tests and run the .rb file eg Ruby find_and_replace_in_all_thermal_zone_names_test.rb all appear ok . Which suggests I have the basics setup ok. image description.

However If I try and run any of the other local test scripts, it generally throws an identical error See second screen shot image description

This error is common to most scripts.

I'm sure its a simple set-up or pathing issue. But why one script would run but no others is odd. Any pointers ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-10-17 10:21:15 -0600

You should be able to run the tests using the openstudio CLI rather than calling ruby directly. The openstudio CLI has ruby embedded inside it along with many of the gems (in this case, the openstudio-extension gem) that you need.

So try:

C:\openstudio-3.6.1\bin\openstudio.exe change_building_location_test.rb

edit flag offensive delete link more


Thanks. I will try to load the Gem file/extension and see how I get on. As am planning on writing and perhaps modifying some of the existing measures. I'm fairly comfy with C# but not really with Ruby. But will use the CMD line if I don't have any luck getting Ruby setup.

Redline's avatar Redline  ( 2023-10-17 15:12:18 -0600 )edit

BTW Just tried running 2-3 tests directly from CMD line from the SDK 3.5, and they all ran perfectly. So now just need to get my Ruby Environment sorted.

Redline's avatar Redline  ( 2023-10-17 15:19:48 -0600 )edit

This may or may not be useful for you: a Gist on setting up WSL2/Ubuntu/Ruby/OpenStudio.

Denis Bourgeois's avatar Denis Bourgeois  ( 2023-10-20 14:00:37 -0600 )edit

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: 2023-10-17 00:58:19 -0600

Seen: 65 times

Last updated: Oct 17