-
Notifications
You must be signed in to change notification settings - Fork 4
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
Sporadic errors "LoadError: no such file to load -- sass" with JRuby and Sprockets #23
Comments
Assuming you’re trying to use the shim for |
Hmm, that does seem similar - however doesn't seem to explain why it's mostly working just fine, but occasionally fails? We're not overriding any defaults for the I did have If you think there's something in Sprockets 4 likely required for it to be better behaved here, I suppose I'll have to try and upgrade that too. 😬 |
Here is my educated guess: you have |
Ok, thanks a lot. Pretty sure I don't have |
For what it's worth, I'm still able to get this on Sprockets 4, but ran out of time to figure out what is going on. Somehow the
|
sass/sassc-rails#114 seems to be related here. |
Ahh, yes. I was wondering about that. Funnily enough I just recently re-introduced (a couple of weeks ago) use of the But I'll dig further later and try without to confirm the source of the issue and see if I can find an alternate approach. |
Sadly I still seem to be able to replicate the issue with everything outside the source 'https://rubygems.org'
ruby '2.6.8'
gem 'rails'
gem 'sassc-rails'
gem 'sassc', github: 'sass/sassc-ruby', ref: 'refs/pull/233/head'
gem 'sassc-embedded'
gem 'sass-embedded', github: 'ntkme/sass-embedded-host-ruby', ref: 'main'
gem 'js-routes'
gem 'ts_routes'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
group :development, :test do
# make sure to `System.setProperty("jruby.runtime.arguments", "--debug")` before opening up pry
gem 'pry-debugger-jruby', platforms: :jruby
end
group :test do
gem 'capybara'
gem 'rspec-rails'
gem 'rspec-instafail', require: false
gem 'rspec_junit_formatter'
gem 'rails-controller-testing'
end |
The only pattern I can find here is that
Still no real ideas though. |
Here is how it works:
Step 3 is supposed to override the functions defined in step 1 to prevent calling |
If you can add some log in the 3 files that have been mentioned above, and see how they are getting loaded, I think it will help understand the problem. |
I tried a bit of logging in the various files, in initializers, and in the I'd just see a single call in the about-to-fail compile to a non-overridden It's also quite possible it has nothing to do with |
Will close this for now, on the assumption that it's something in my environment, a problem within sassc-rails or something with sprockets/zeitwork/whatever - and likely nothing to do with this tool. My only suggestion for the |
@chadlwilson The problem is due to lack of thread safety in |
Oh wow. Any suggestions of whether that can be mitigated on the user side? |
I even got a mininum reproduction for this: # Gemfile
source "https://rubygems.org"
# uncomment the comment in the next line to test the patch
gem 'sprockets' #, github: 'ntkme/sprockets', branch: 'module-include-thread-safety'
gem 'sassc-rails'
gem 'sassc', github: 'sass/sassc-ruby', ref: 'refs/pull/233/head'
gem 'sassc-embedded' # test.rb
require 'sassc/rails'
class MockContext < Hash
def metadata
{}
end
def asset_path(path, options)
"#{path}"
end
end
class MockEnvironment
def context_class
MockContext
end
def paths
[]
end
end
class MockSassConfig
def inline_source_maps
false
end
def line_comments
false
end
def style
:expanded
end
def load_paths
[]
end
end
class MockConfig
def sass
MockSassConfig.new
end
end
class MockApplication
def config
MockConfig.new
end
end
module Rails
def self.application
MockApplication.new
end
end
threads = []
10.times do
threads << Thread.new do
puts SassC::Rails::SassTemplate.call({
data: '''
sass
a: asset_url("test")
''',
environment: MockEnvironment.new
})
end
end
threads.each do |t|
t.join
end |
Monkey patch a mutex around |
Yes, I tested locally and that definitely works. I will submit a PR to upstream to fix it. |
Looks like they are still merging PRs on Sprockets and periodically releasing which is promising if there's any chance of addressing it upstream. |
I'm not really sure what is going on here, but would appreciate any tips - please go gentle, I'm not a Rails/Sprockets expert 😅. Apologies if this should be reported at the other project; I'm not really sure.
When working in
development
mode with hot-reloading and the autoloader, every now and then (but reasonably frequently) I get the below error. I can't work out a pattern as to what is happening. When this happens the browser will block. If I kill the request and try again it will usually work OK but then occur again later.I have also had it happen when pre-compiling assets too, so perhaps it is to do with some kind of race condition or threading type of issue with JRuby or sprockets? If you suspect I need to upgrade to Sprockets 4, that's fine. Haven't noticed a similar issue earlier when using ruby-sass.
Environment:
JRuby 9.3.7.0 (Ruby 2.6 compatible)
Rails 6.1.6.1 in Zeitwork mode
Sprockets 3.7.2 (haven't yet moved to 4.1, was earlier blocked by another dependency)
The text was updated successfully, but these errors were encountered: