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

Setting up Ruby Environment for Measures in Win 10 is Ruby 3.x supported?

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

Redline's avatar

updated 2024-03-17 18:50:25 -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

2 Answers

Sort by ยป oldest newest most voted
1

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

Comments

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
0

answered 2024-03-10 18:00:05 -0600

Redline's avatar

An update to my original question: I have Ruby 2.7.2 Installed and can run any of the Test scripts in the measures Github repo (openstudio-common-measures-gem-develop). Which is fine, I can also run any test from the OpenStudio CLI.

The ruby version seems critical, and has to be as per the OpenStudio version compatibility matrix in order for any of the measures to be run in an IDE.

However most IDE tools like VScode etc all assume ruby 3.x is installed.

Most of the debuggers and extensions for VScode (rdbg, lsp etc) wont work with Ruby 2.x.

IF you install a newer version of Ruby , then all of the OS measures scripts wont run as they fail the initial version checks.

Are there any plans to update OpenStudio to run on a newer version of Ruby. As it would be great to be able to take an existing measures script and run it in debug mode line by line?

edit flag offensive delete link more

Comments

1

@Redline since this is an update to your question instead of an answer, would you mind editing your original question to add this information?

Aaron Boranian's avatar Aaron Boranian  ( 2024-03-11 08:03:27 -0600 )edit

I've edited the original Q to include Ruby version. But still don't know if there are plans to update OS to use newer versions of Ruby.

Redline's avatar Redline  ( 2024-03-17 18:52:02 -0600 )edit

@Redline The current plan is for OpenStudio 3.8 (planned release: May 17, 2024) to include ruby 3.2.2.

shorowit's avatar shorowit  ( 2024-03-18 09:52:44 -0600 )edit

Thanks will keep an eye out for it.

Redline's avatar Redline  ( 2024-03-20 15:17:07 -0600 )edit

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

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

Seen: 262 times

Last updated: Mar 17