waynerobinson / xeroizer

Xero accounting system API library.
http://waynerobinson.github.com/xeroizer
Other
239 stars 311 forks source link

Missing require somewhere: "uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState" when used outside of Rails #555

Open matthewbloch opened 2 years ago

matthewbloch commented 2 years ago

I think that Xeroizer has forgotten to require 'active_support/isolated_execution_state' somewhere, which presumably gets done automatically in Rails. This is currently what happens when you try to require xeroizer outside of Rails:

$ cat Gemfile
source 'https://rubygems.org/'
gem 'xeroizer'
$ cat test.rb
#!/usr/bin/ruby
require 'xeroizer'
$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching concurrent-ruby 1.1.9
Installing concurrent-ruby 1.1.9
Fetching i18n 1.8.11
Installing i18n 1.8.11
Fetching minitest 5.15.0
Installing minitest 5.15.0
Fetching tzinfo 2.0.4
Installing tzinfo 2.0.4
Fetching activesupport 7.0.0
Installing activesupport 7.0.0
Fetching builder 3.2.4
Installing builder 3.2.4
Using bundler 2.1.4
Fetching faraday-em_http 1.0.0
Installing faraday-em_http 1.0.0
Fetching faraday-em_synchrony 1.0.0
Installing faraday-em_synchrony 1.0.0
Fetching faraday-excon 1.1.0
Installing faraday-excon 1.1.0
Fetching faraday-httpclient 1.0.1
Installing faraday-httpclient 1.0.1
Fetching faraday-net_http 1.0.1
Installing faraday-net_http 1.0.1
Fetching faraday-net_http_persistent 1.2.0
Installing faraday-net_http_persistent 1.2.0
Fetching faraday-patron 1.0.0
Installing faraday-patron 1.0.0
Fetching faraday-rack 1.0.0
Installing faraday-rack 1.0.0
Fetching multipart-post 2.1.1
Installing multipart-post 2.1.1
Fetching ruby2_keywords 0.0.5
Installing ruby2_keywords 0.0.5
Fetching faraday 1.8.0
Installing faraday 1.8.0
Fetching jwt 2.3.0
Installing jwt 2.3.0
Fetching mini_portile2 2.6.1
Installing mini_portile2 2.6.1
Fetching multi_json 1.15.0
Installing multi_json 1.15.0
Fetching multi_xml 0.6.0
Installing multi_xml 0.6.0
Fetching racc 1.6.0
Installing racc 1.6.0 with native extensions
Fetching nokogiri 1.12.5 (x86_64-linux)
Installing nokogiri 1.12.5 (x86_64-linux)
Fetching oauth 0.5.8
Installing oauth 0.5.8
Fetching rack 2.2.3
Installing rack 2.2.3
Fetching oauth2 1.4.7
Installing oauth2 1.4.7
Fetching xeroizer 3.0.1
Installing xeroizer 3.0.1
Bundle complete! 1 Gemfile dependency, 28 gems now installed.
Bundled gems are installed into `./vendor/bundle`
$ bundle exec ./test.rb
Traceback (most recent call last):
        11: from ./test.rb:2:in `<main>'
        10: from ./test.rb:2:in `require'
         9: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/xeroizer-3.0.1/lib/xeroizer.rb:5:in `<top (required)>'
         8: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/xeroizer-3.0.1/lib/xeroizer.rb:5:in `require'
         7: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/core_ext/array.rb:5:in `<top (required)>'
         6: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/core_ext/array.rb:5:in `require'
         5: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/core_ext/array/conversions.rb:3:in `<top (required)>'
         4: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/core_ext/array/conversions.rb:3:in `require'
         3: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/xml_mini.rb:11:in `<top (required)>'
         2: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/xml_mini.rb:201:in `<module:ActiveSupport>'
         1: from /home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/xml_mini.rb:103:in `backend='
/home/mattbee/journalx/testxeroizer/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/xml_mini.rb:184:in `current_thread_backend': uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState (NameError)

Obviously the workaround is just to require 'active_support/isolated_execution_state' before require 'xeroizer'.

matthewbloch commented 2 years ago

I think this is a bug in ActiveSupport 7 https://github.com/rails/rails/issues/43851

zarqman commented 2 years ago

It is a change in ActiveSupport 7 (I've seen it crop up in a couple different places already too), but apparently is by design per rails/rails#44450. The suggested fix is to add require "active_support" (which sets up a bunch of autoloads) to somewhere in Xeroizer's loading sequence.

CloCkWeRX commented 4 months ago

PRs welcome for this.

https://github.com/waynerobinson/xeroizer/blob/master/lib/xeroizer.rb is what is done now