Skip to content
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

incompatible with sinatra 4.0 / rack 3.0 #705

Open
namiwang opened this issue Feb 6, 2024 · 5 comments
Open

incompatible with sinatra 4.0 / rack 3.0 #705

namiwang opened this issue Feb 6, 2024 · 5 comments

Comments

@namiwang
Copy link

namiwang commented Feb 6, 2024

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.

@kebugcheckex
Copy link

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.

@yuanworks
Copy link

yuanworks commented May 30, 2024

@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 #709

@philosophicles
Copy link

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.

@pboling
Copy link

pboling commented Sep 19, 2024

Here's the answer (most likely).

You need to add the rackup gem to your dependencies in order to be compatible with rack v3.

gem "rackup"

@pboling
Copy link

pboling commented Sep 19, 2024

@yuanworks You would also need to replace your line that looks like this:

Rack::Handler::WEBrick.run server

with a line that looks like this:

Rackup::Server.start app: server

where server is something like:

server = Rack::Builder.new do 
  # ...
end

Note: it will still run WEBrick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants