Skip to content
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

Runtime error when running urbanopt cli example project #227

Closed
tijcolem opened this issue May 12, 2021 · 2 comments · Fixed by urbanopt/urbanopt-scenario-gem#211
Closed
Labels
bug Something isn't working

Comments

@tijcolem
Copy link
Contributor

Expected behavior

When using the latest urbanopt cli 0.6.0, the example project fails to run after it's been created.

Actual behavior

Runtime errors associated with Globals being redefined and stack overflow presumably due to some infinite loop.

To Reproduce

Steps to reproduce the behavior:

Using ruby 2.7.2 on linux, mac or windows.

gem install urbanopt-cli
uo create -p urbanopt_example_project
uo create -s urbanopt_example_project/example_project.json
uo run -f urbanopt_example_project/example_project.json -s urbanopt_example_project/baseline_scenario.csv 

Snippets of relevant output of run command above

Simulating features of 'example_project.json' as directed by 'baseline_scenario.csv'...

adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/rexml-3.2.4/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/minitest-5.14.4/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/ast-2.4.2/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/parser-3.0.1.1/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/openstudio_measure_tester-0.3.0/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/builder-3.2.4/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/rubocop-0.54.0/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/urbanopt-geojson-0.6.2/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/octokit-4.18.0/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/git-1.6.0/lib
adding DIR to load path: /home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/docile-1.4.0/lib
...
/home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:4: warning: already initialized constant JSON::VERSION
/var/lib/gems/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:4: warning: previous definition of VERSION was here
/home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:5: warning: already initialized constant JSON::VERSION_ARRAY
/var/lib/gems/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:5: warning: previous definition of VERSION_ARRAY was here
/home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:6: warning: already initialized constant JSON::VERSION_MAJOR
/var/lib/gems/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:6: warning: previous definition of VERSION_MAJOR was here
/home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:7: warning: already initialized constant JSON::VERSION_MINOR
/var/lib/gems/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:7: warning: previous definition of VERSION_MINOR was here
/home/ubuntu/urbanopt_example_project/.bundle/install/ruby/2.7.0/gems/json_pure-2.5.1/lib/json/version.rb:8: warning: already initialized constant JSON::VERSION_BUILD
...
Traceback (most recent call last):
	10909: from /usr/local/bin/uo:23:in `<main>'
	10908: from /usr/local/bin/uo:23:in `load'
	10907: from /var/lib/gems/2.7.0/gems/urbanopt-cli-0.6.0/bin/uo:3:in `<top (required)>'
	10906: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	10905: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	10904: from /var/lib/gems/2.7.0/gems/urbanopt-cli-0.6.0/lib/uo_cli.rb:56:in `<top (required)>'
	10903: from /var/lib/gems/2.7.0/gems/urbanopt-cli-0.6.0/lib/uo_cli.rb:57:in `<module:URBANopt>'
	10902: from /var/lib/gems/2.7.0/gems/urbanopt-cli-0.6.0/lib/uo_cli.rb:728:in `<module:CLI>'
	 ... 10897 levels...
	    4: from /var/lib/gems/2.7.0/gems/rexml-3.2.4/lib/rexml/xmldecl.rb:83:in `encoding='
	    3: from /var/lib/gems/2.7.0/gems/rexml-3.2.4/lib/rexml/xmldecl.rb:83:in `encoding='
	    2: from /var/lib/gems/2.7.0/gems/rexml-3.2.4/lib/rexml/xmldecl.rb:81:in `encoding='
	    1: from /var/lib/gems/2.7.0/gems/rexml-3.2.4/lib/rexml/xmldecl.rb:81:in `puts'
/var/lib/gems/2.7.0/gems/rexml-3.2.4/lib/rexml/xmldecl.rb:81:in `puts': stack level too deep (SystemStackError)

Additional context

I believe the issue is this block of code and it's very subtle but has unintended consequences.
https://github.com/urbanopt/urbanopt-scenario-gem/blob/develop/lib/urbanopt/scenario/scenario_csv.rb#L108
The issue is its loading gems in .bundle dir as the example directory includes "urbanopt" and it matches the pattern and causes run time issues as it essentially loads in all gems and many of these are duplicates. Simply renaming the directory from urbanopt_example_project to example_project everything works fine.

@tijcolem tijcolem added the bug Something isn't working label May 12, 2021
@vtnate
Copy link
Collaborator

vtnate commented May 13, 2021

Wow, thanks @tijcolem. If we prevent users from creating project directories with urbanopt or openstudio in the names, would that be an acceptable solution?

@vtnate
Copy link
Collaborator

vtnate commented May 13, 2021

@rawadelkontar Is there a better way we can look for gems in the line Tim highlighted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants