-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unset ruby envs in openstudio_cli.rb #4068
Conversation
This is related to https://github.com/NREL/openstudio-extension-gem/blob/develop/lib/openstudio/extension/runner.rb#L183 Be careful here because there are a lot of possible use cases here (e.g calling the CLI to do standards sizing run in workflow using a bundle, etc) |
Thanks for the heads up @macumber. My understanding with the recent changes of how bundler works as of version > 3.0.1, openstudio_cli.rb should only explicitly set these ruby envs based on arguments to the CLI (e.g. --gem_home). It should never use the parent process envs by doing something like:
As far as openstudio-gems, I looked into these and did a simple The only other thing I can think of is ruby bindings but that gets set up by the wrapper - https://github.com/NREL/OpenStudio/blob/develop/ruby/openstudio.rb and we are not modifying those envs there. I think these changes are what we want and just unset these to prevent unwanted usage in the CLI unless you know of a use case that might cause issues? I can't think of any of looking through things. |
Are these still accepted as command line arguments?
https://github.com/NREL/OpenStudio/blob/develop/src/cli/openstudio_cli.rb#L387 I think this is used in URBANopt: https://github.com/urbanopt/urbanopt-scenario-gem/blob/c4570c9fcf6676d4ff8a17b94a9adf950d515fbd/lib/urbanopt/scenario/scenario_runner_osw.rb#L89 It gets passed in to the extension runner: https://github.com/NREL/openstudio-extension-gem/blob/develop/lib/openstudio/extension/runner.rb#L88 |
The biggest use case to me was to be able to use different versions of the OpenStudio Standards Gem. URBANopt was built around the idea that each project would have a Gemfile that pulls in all the URBANopt gems you want for your project. |
Yep, those are all still excepted args to the cli so no changes there. So you can still do this if you wanted to use a custom openstudio-standards gem. 1 ) Create simple Gemfile for custom openstudio-standards
2 ) Install gems via bundler 3 ) Run cli with custom gems Note that the above workflow is unique to OpenStudio versions > 3.0.1 as you now only need to install the gems you want to use with OpenStudio vs all gems. I don't think we want this anymore: https://github.com/NREL/OpenStudio/blob/develop/src/cli/openstudio_cli.rb#L416-L418 Thanks for pointing it out. The idea here is to drive the CLI with args only and not accept ruby envs from the shell since many users have rvm which sets these automatically and causes unwanted behavior in the CLI. |
Sounds good Tim! |
Building develop, without this fix:
Building this PR
@tijcolem Works for me! thanks for the fix. |
EDIT: FALSE ALARMIt was picking up my system ruby's bundler at 1.1.16.
now I have 2.1.4 on my system ruby and the test runs just fine. Original:
|
OpenStudio/src/cli/openstudio_cli.rb Lines 372 to 374 in d21ad25
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested that everything works fine for me and that it does fix the problem
…e external ENVs into the cli anymore
CI Results for c71989c:
|
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)src/openstudio_lib/library/OpenStudioPolicy.xml
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.