Closed jhottenstein closed 3 years ago
I see that 3.0.0 just dropped. I can try upgrading.
Same problem occurred to me with Jets 3.0.0. I have fixed it adding version lock for nokogiri.
# Gemfile
gem 'nokogiri', '~> 1.10.0'
@ryz310 Unsure what's going on there 🧐 Just tested it and was able to use the latest version of nokogiri.
Here's a simple test controller:
require 'open-uri'
class NokogiriController < ApplicationController
def index
# Fetch and parse HTML document
doc = Nokogiri::HTML(URI.open('https://nokogiri.org/tutorials/installing_nokogiri.html'))
# Search for nodes by css
content = nil
doc.css('nav ul.menu li a', 'article h2').each do |link|
content = link.content
end
render json: {
content: content,
nokogiri_version: Nokogiri::VERSION,
jets_version: Jets::VERSION,
ruby_version: RUBY_VERSION,
}
end
end
Here's the debugging output from the Jets app on AWS Lambda.
$ curl https://ykmipzptqc.execute-api.us-west-2.amazonaws.com/dev/ ; echo
{"content":"Appendix A: The Compiler Toolchain¶","nokogiri_version":"1.11.1","jets_version":"3.0.0","ruby_version":"2.7.2"}
$ curl -s https://ykmipzptqc.execute-api.us-west-2.amazonaws.com/dev/ | jq
{
"content": "Appendix A: The Compiler Toolchain¶",
"nokogiri_version": "1.11.1",
"jets_version": "3.0.0",
"ruby_version": "2.7.2"
}
$
Code is also here: https://github.com/tongueroo/jets-nokogiri-demo
Ah, thanks for the reply. I'll try it out. I was able to repro with just running the quick start (minus db code). I modified the original bug report.
Your project gave me the same error:
$ curl https://szg6nfeohb.execute-api.us-east-1.amazonaws.com/dev/ ; echo
{"message": "Internal server error"}
$ jets call nokogiri-controller-index '{"test":1}'|jq
Calling lambda function nokogiri-dev-nokogiri_controller-index on AWS
Function name: nokogiri-dev-nokogiri_controller-index
Pro tip: The Lambda Console Link to the nokogiri-dev-nokogiri_controller-index function has been added to your clipboard.
{
"errorMessage": "Could not find nokogiri-1.11.1 in any of the sources",
"errorType": "Init<Bundler::GemNotFound>",
"stackTrace": [
"/var/runtime/gems/bundler-2.1.4/lib/bundler/spec_set.rb:86:in `block in materialize'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in `map!'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in `materialize'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/definition.rb:237:in `specs_for'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/definition.rb:226:in `requested_specs'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/runtime.rb:101:in `block in definition_method'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/runtime.rb:20:in `setup'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler.rb:149:in `setup'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `block in <top (required)>'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136:in `with_level'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88:in `silence'",
"/var/runtime/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/task/handlers/controllers/nokogiri_controller.rb:1:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:72:in `require'",
"/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:72:in `require'"
]
}
Gem layer: I believe the issue is that nokogiri-1.11.1-x86_64-darwin is in the gem directory.
That was a tough one. Seems like ruby and/or bundler changed the way gems can be installed, which changes the way native gem detection works. Fixed. Try upgrading to jets v3.0.2 and then:
rm -rf /tmp/jets
jets deploy
In my case, when I fixed the version to 1.9.1 to avoid using nokogiri's 1.11, I got an error related to liblzma
, so I fixed it to 1.10 and that solved the problem.If you're having same trouble, please refer to the following.
liblzma.so.5: cannot open shared object file: No such file or directory - /opt/ruby/gems/2.7.0/gems/nokogiri-1.9.1/lib/nokogiri/nokogiri.so
- gem 'nokogiri', '1.9.1'
+ gem 'nokogiri', '~> 1.10.0'
Had to do with gem detection and specific versions of nokogiri gem. Fixed in #529 It was already fixed in Jets v3. Also, released in jets v2.3.19.
Checklist
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/My Environment
I deploy directly from my machine
Expected Behaviour
Lambda functions do not crash at startup
Current Behavior
All lambda functions crash at startup
Step-by-step reproduction instructions
Run a more basic version of the quick start guide
I had to downgrade nokogiri to 1.10.x