Web app can't load Sinatra when deployed

I am able to run my sinatra web app locally just fine, but when I deploy it on Render, I am getting the following error:

Oct 23 11:45:58 PM from app.rb:1:in <main>' Oct 23 11:46:18 PM ==> Starting service with 'ruby app.rb' Oct 23 11:46:20 PM <internal:/opt/render/project/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in require’: cannot load such file – sinatra (LoadError)

For context, here’s the top of my app.rb file, where the error is raised:
require 'sinatra'

And here’s what my Gemfile looks like:

source "https://rubygems.org"

ruby "3.0.0"

gem "sinatra"
gem "sinatra-contrib"
gem "erubis"
gem "rack-test"
gem "minitest"
gem 'webrick'

My best guess is that even though ‘bundle install’ downloads Sinatra during the build phase, Render’s version manager isn’t looking in the right place for it when my app.rb file requires Sinatra. Am I on the right track here? Is there a way to troubleshoot this issue with my free Render account?

Thank you in advance!

Hi there,

Thanks for reaching out.

It’s been a while since I’ve used Sinatra, but I think booting it through ruby is for development maybe?

For production deploys of Sinatra apps, I always used to boot them with rack. Could you try using rackup -p $PORT as your Start Command to see if that helps?



This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.