sass-contrib / sassc-embedded-shim-ruby

:gem: A Ruby shim for SassC that will communicate with Embedded Dart Sass using the Embedded Sass protocol
https://rubygems.org/gems/sassc-embedded
MIT License
20 stars 4 forks source link

SassC::SyntaxError / Sass::CompileError: End of file reached without feedback on Jruby with Java 16+ #22

Closed chadlwilson closed 2 years ago

chadlwilson commented 2 years ago

HI there - thanks for this project, it looks promising to make a migration away from ruby-sass and libsass possible, since dartsass-rails doesn't seem to be as nicely integrated with Rails/Sprockets as we'd like for development purposes and getting libsass to compile for Windows seems to be a bit of a nightmare; not worth the effort for something deprecated (supporting Windows dev/test is currently a requirement for us).

I'm parking this here as came across an issue that might be of use to others on JRuby.

When pre-compiling assets for test or production under JRuby it's possibIe to get errors like the below, but no feedback on the problematic file. When in development mode, things just hang in JRuby threads without feedback - you can see forked dart processes, but JRuby-land is just waiting for responses.

Environment

Problem

Getting error with rake assets:clobber assets:precompile --trace via JRuby

SassC::SyntaxError: /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/async.rb:56:in `block in await': End of file reached (Sass::CompileError)
        from org/jruby/ext/thread/Mutex.java:171:in `synchronize'

There is no other feedback on the problem, or what it was trying to do. What is actually happening is that forking dartsass seems to require "Native subprocess control" which is restricyed on Java 16+. Normally JRuby will warn you with

2022-09-09T14:01:31.317+08:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.

Solution

Ensure you have these args (--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED) to your JVM JRuby is running in, and sassc-embedded-shim-ruby will work correctly.

I suspect this project isn't necessarily validated with JRuby, so wanted to note this here. I also suspect the "feedback" problem isn't so much this project's problem as some challenge with our setup, or JRuby itself. So we can probably close this immediately :-)

Fuller log

Using environment variables
    GEM_HOME='/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0' \
    GEM_PATH='/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0' \
        PATH='/Users/chad/Projects/community/gocd/gocd/server/scripts:/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/bin:/Users/chad/.local/bin:/Users/chad/go/bin:/usr/local/sbin:/Users/chad/.asdf/shims:/Users/chad/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' \
   RAILS_ENV='test' \
RAILS_GROUPS='assets' \
        RUBY='/Users/chad/Projects/community/gocd/gocd/server/scripts/jruby' \
[/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails]$ java -Djruby.home=uri:classloader://META-INF/jruby.home -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xss2048k -client -Dfile.encoding=UTF-8 -Duser.country=SG -Duser.language=en -Duser.variant org.jruby.Main -S rake assets:clobber assets:precompile --trace
2022-09-09T13:49:03.937+08:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.
** Invoke assets:clobber (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/js-routes-1.4.14/lib/js_routes.rb:22: warning: Dir.exists? is a deprecated name, use Dir.exist? instead
** Execute assets:clobber
I, [2022-09-09T13:49:14.648612 #61099]  INFO -- : Removed /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/public/assets
** Invoke assets:precompile (first_time)
** Invoke assets:environment
** Execute assets:precompile
I, [2022-09-09T13:49:14.984946 #61099]  INFO -- : Writing /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/public/assets/lib/d3-3.1.5.min-586e3ae81fb89e3ab168586419d4588eebe30e705122844359e8156ed2c2545f.js
rake aborted!
SassC::SyntaxError: /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/async.rb:56:in `block in await': End of file reached (Sass::CompileError)
        from org/jruby/ext/thread/Mutex.java:171:in `synchronize'
        from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/async.rb:53:in `await'
        from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/host.rb:133:in `await'
        from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/host.rb:43:in `compile_request'
        from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded.rb:209:in `compile_string'
        from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded.rb:47:in `compile_string'
        from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sassc-embedded-1.54.0/lib/sassc/embedded.rb:17:in `render'
        from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sassc-rai

.... (snip)

Caused by:
Sass::CompileError: End of file reached
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/async.rb:56:in `block in await'
org/jruby/ext/thread/Mutex.java:171:in `synchronize'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/async.rb:53:in `await'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/host.rb:133:in `await'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded/host.rb:43:in `compile_request'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded.rb:209:in `compile_string'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sass-embedded-1.54.9/lib/sass/embedded.rb:47:in `compile_string'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sassc-embedded-1.54.0/lib/sassc/embedded.rb:17:in `render'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:40:in `block in call'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/utils.rb:171:in `module_include'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:39:in `call'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/sass_processor.rb:30:in `call'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
org/jruby/RubyArray.java:1947:in `reverse_each'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
org/jruby/RubyHash.java:794:in `default'
org/jruby/RubyHash.java:1265:in `[]'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/bundle.rb:23:in `block in call'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/utils.rb:200:in `dfs'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/bundle.rb:24:in `call'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
org/jruby/RubyArray.java:1947:in `reverse_each'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
org/jruby/RubyHash.java:794:in `default'
org/jruby/RubyHash.java:1265:in `[]'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:134:in `block in find'
org/jruby/RubyArray.java:1865:in `each'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:133:in `find'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:67:in `block in define'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:66:in `block in define'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
org/jruby/RubyArray.java:1865:in `each'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
org/jruby/ext/monitor/Monitor.java:82:in `synchronize'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
org/jruby/RubyArray.java:1865:in `each'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/gems/jruby/2.6.0/gems/rake-13.0.6/exe/rake:27:in `<main>'
org/jruby/RubyKernel.java:1052:in `load'
uri:classloader:/META-INF/jruby.home/bin/rake:23:in `<main>'
ntkme commented 2 years ago

The tests in GitHub Actions run with JRuby on Java 11 today, so that it does not expose the issue you're facing.

And yes, this is a JRuby issue: https://github.com/jruby/jruby/issues/6721

chadlwilson commented 2 years ago

@ntkme Thank you! I am previously aware of the underlying JRuby problem after doing a Java 17 migration, but it's a bit weird that one doesn't get any feedback or see the normal error from the JVM subsystem when you try to access something you're not allowed to. That's probably a separate JRuby quirk that it's swallowing the root cause error somehow.