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

Revision history [back]

I do not ever set these variables in the .bash_profile. I just symlink the openstudio CLI you want to use in /usr/local/bin (or equivalent).

For use in interactive ruby, I use pry with a .pryrc personally. (gem install pry).

You can just write ruby code to be executed before the session starts.

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.3")
  # Do something
else
  # Do something else
end

I have a prompt actually that allows me to select either openstudio installed or my local builds

print "Do you want OpenStudio (os) or os-debug (1) / os-release (2), or os-app-debug (3) / os-app-release (4): [os/1/2/3/4] "
input = gets.strip

# This typically loads a custom build installed on my computer
if input == '1'
  p = File.join(ENV["HOME"], "Software/Others/OS-build/Products/ruby/openstudio")
elsif input == '2'
  p = File.join(ENV["HOME"], "Software/Others/OS-build-release/Products/ruby/openstudio")
elseif ...

else
  p = 'openstudio' # Installed openstudio
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"

In your case, you can revamp that easily to have that prompt require either 2.8.1 or 2.9.1

print "Do you want OpenStudio 2.8.1 (1) or 2.9.1 (2): [1/2] "
input = gets.strip

# This typically loads a custom build installed on my computer
if input == '1':
    p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_8_1/Ruby/openstudio'
else
   p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_9_1/Ruby/openstudio
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"

I do not ever set these variables in the .bash_profile. I just symlink the openstudio CLI you want to use in /usr/local/bin (or equivalent).

For use in interactive ruby, I use pry with a .pryrc personally. (gem install pry).

You can just write ruby code to be executed before the session starts.

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.3")
  # Do something
else
  # Do something else
end

I have a prompt actually that allows me to select either openstudio installed or my local builds

print "Do you want OpenStudio (os) or os-debug (1) / os-release (2), or os-app-debug (3) / os-app-release (4): [os/1/2/3/4] "
input = gets.strip

# This typically loads a custom build installed on my computer
if input == '1'
  p = File.join(ENV["HOME"], "Software/Others/OS-build/Products/ruby/openstudio")
elsif input == '2'
  p = File.join(ENV["HOME"], "Software/Others/OS-build-release/Products/ruby/openstudio")
elseif ...

else
  p = 'openstudio' # Installed openstudio
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"

In your case, you can revamp that easily to have that prompt require either 2.8.1 or 2.9.1

print "Do you want OpenStudio 2.8.1 (1) or 2.9.1 (2): [1/2] "
input = gets.strip

# This typically loads a custom build installed on my computer
if input == '1':
    p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_8_1/Ruby/openstudio'
else
   p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_9_1/Ruby/openstudio
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"

I do not ever set these variables in the .bash_profile. I just symlink the openstudio CLI you want to use in /usr/local/bin (or equivalent).

For use in interactive ruby, I use pry with a .pryrc personally. (gem install pry).

You can just write ruby code to be executed before the session starts.

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.3")
  # Do something
else
  # Do something else
end

I have a prompt actually that allows me to select either openstudio installed or my local builds

print "Do you want OpenStudio (os) or os-debug (1) / os-release (2), or os-app-debug (3) / os-app-release (4): [os/1/2/3/4] "
input = gets.strip

# This typically loads a custom build installed on my computer
if input == '1'
  p = File.join(ENV["HOME"], "Software/Others/OS-build/Products/ruby/openstudio")
elsif input == '2'
  p = File.join(ENV["HOME"], "Software/Others/OS-build-release/Products/ruby/openstudio")
elseif ...

else
  p = 'openstudio' # Installed openstudio
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"

In your case, you can revamp that easily to have that prompt require either 2.8.1 or 2.9.1

print "Do you want OpenStudio 2.8.1 (1) or 2.9.1 (2): [1/2] "
input = gets.strip

if input == '1':
   p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_8_1/Ruby/openstudio'
else
   p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_9_1/Ruby/openstudio
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"

I do not ever set these variables in the .bash_profile. I just symlink the openstudio CLI you want to use in /usr/local/bin (or equivalent).

For use in interactive ruby, I use pry with a .pryrc personally. (gem install pry).

You can just write ruby code to be executed before the session starts.

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.3")
  # Do something
else
  # Do something else
end

I have a prompt actually that allows me to select either openstudio installed or my local builds

print "Do you want OpenStudio (os) or os-debug (1) / os-release (2), or os-app-debug (3) / os-app-release (4): [os/1/2/3/4] "
input = gets.strip

# This typically loads a custom build installed on my computer
if input == '1'
  p = File.join(ENV["HOME"], "Software/Others/OS-build/Products/ruby/openstudio")
elsif input == '2'
  p = File.join(ENV["HOME"], "Software/Others/OS-build-release/Products/ruby/openstudio")
elseif ...

else
  p = 'openstudio' # Installed openstudio
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"

In your case, you can revamp that easily to have that prompt require either 2.8.1 or 2.9.1

print "Do you want OpenStudio 2.8.1 (1) or 2.9.1 (2): [1/2] "
input = gets.strip

if input == '1':
  p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_8_1/Ruby/openstudio'
else
  p = '/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_9_1/Ruby/openstudio
'/Users/home/Desktop/App/Run/OpenStudio/OpenStudio_2_9_1/Ruby/openstudio'
end

require p
puts "Loading '#{p}': #{OpenStudio::openStudioLongVersion}"