jekyll-admin icon indicating copy to clipboard operation
jekyll-admin copied to clipboard

incompatible with sinatra 4.0 / rack 3.0

Open namiwang opened this issue 1 year ago • 5 comments

After upgrading sinatra (which jekyll-admin depends on) to 4.0, got the following error when staring server

bundler: failed to load command: jekyll (/Users/nami/.asdf/installs/ruby/3.2.2/bin/jekyll)
<internal:/Users/nami/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require': cannot load such file -- rack/handler (LoadError)
	from <internal:/Users/nami/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from /Users/nami/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jekyll-admin-0.11.1/lib/jekyll/commands/serve.rb:23:in `jekyll_admin_monkey_patch'
	from /Users/nami/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jekyll-admin-0.11.1/lib/jekyll/commands/serve.rb:15:in `start_up_webrick'
...

The root cause is sinatra 4 dropped support for rack 2

refs:

A workaround is to add gem "rackup" to Gemfile.

A simple fix would be limiting spec.add_dependency "sinatra", ">= 1.4", "< 4.0" in gemspec, or adding rackup as a direct dependency.

namiwang avatar Feb 06 '24 05:02 namiwang

Github Dependabot sent me multiple security alerts regarding rack version used in jekyll-admin. rack should be upgraded to at least 2.2.8.1. Upgrading sinatra to 4 will solve the problem.

kebugcheckex avatar Mar 15 '24 04:03 kebugcheckex

@namiwang unfortunately your fix (adding rackup gem) doesn't let me save new pages inside the admin because of the following error:

 NoMethodError - undefined method `rewind' for #<Rackup::Handler::WEBrick::Input

I managed to get both admin and saving files working by downgrading sinatra:

gem "sinatra", ">= 3", "< 4"

Edit: issue mentioned here too https://github.com/jekyll/jekyll-admin/issues/709

yuanworks avatar May 30 '24 19:05 yuanworks

I've had similar but not identical issues today after forking from an old jekyll theme, switching on dependabot, and it asking for some massive version leaps in both rack and jekyll-admin.

jekyll 3.9.5 | Error:  uninitialized constant Rack::Handler
/usr/local/lib/ruby/gems/3.3.0/gems/jekyll-admin-0.11.1/lib/jekyll/commands/serve.rb:23:in `jekyll_admin_monkey_patch': uninitialized constant Rack::Handler (NameError)

          @server.mount "/admin", Rack::Handler::WEBrick, JekyllAdmin::StaticServer
                                      ^^^^^^^^^
	from /usr/local/lib/ruby/gems/3.3.0/gems/jekyll-admin-0.11.1/lib/jekyll/commands/serve.rb:15:in `start_up_webrick'
	from /usr/local/lib/ruby/gems/3.3.0/gems/jekyll-3.9.5/lib/jekyll/commands/serve.rb:104:in `process'
...

Thanks @yuanworks : after trying various other fix suggestions from around the internet, downgrading sinatra to 3.x (3.2.0 specifically) did the trick for me.

I am not normally a ruby person and a little lost in this dependency mire, but commenting in case this helps anyone else out.

philosophicles avatar Jun 13 '24 20:06 philosophicles