/replit-tutorials

How to manage Rails dependencies in Replit

Learn how to manage Rails dependencies in Replit with simple steps, from bundler setup to smooth updates for fast, reliable development.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to manage Rails dependencies in Replit

You manage Rails dependencies in Replit the same way you do in any normal Ruby/Rails environment: through your Gemfile and Bundler. The main difference is that Replit runs everything inside a lightweight Linux container, so you must explicitly install system-level packages, update gems through bundle install, and ensure the environment has the correct Ruby version and build tools. Once your Gemfile is correct, running bundle install in the Replit shell is the reliable way to keep dependencies consistent.

 

What “managing Rails dependencies” means on Replit

 

Rails dependencies come from Ruby gems. These are declared in your Gemfile, locked in Gemfile.lock, and installed using the tool Bundler. Replit doesn’t automatically manage these for you, so you need to treat your Gemfile as the source of truth and use the shell to install or update packages.

  • Gemfile lists what gems your app needs.
  • Gemfile.lock stores the exact versions actually installed.
  • Bundler handles installing and updating those gems.
  • System packages (ex: Node, libvips, sqlite-dev) sometimes must be installed manually through apt.

 

Step-by-step: Correct way to manage Rails dependencies in Replit

 

The steps below reflect how Rails devs actually work inside Replit when building real projects, not just demos.

  • Edit your Gemfile Write or change your gem requirements exactly as you would locally. Example:

    \`\`\`ruby gem "rails", "~> 7.1" gem "pg" // Use PostgreSQL if you're connecting to an external Postgres gem "puma" gem "sass-rails" \`\`\`
  • Install or update gems After editing Gemfile, always run:

    \`\`\`shell bundle install \`\`\`
    This installs gems into the Replit environment. If a gem needs system headers (like sqlite3 or pg), Bundler will fail until those packages are installed using apt.
  • Install missing system packages when Bundler errors Rails gems often depend on Linux libraries. Use apt inside the Replit shell:

    \`\`\`shell sudo apt-get update sudo apt-get install libsqlite3-dev nodejs \`\`\`
    Rule of thumb: If bundling complains about a missing header or library, apt is the fix.
  • Keep Gemfile.lock committed Replit does not regenerate your environment each boot. Keeping the lockfile ensures your environment won’t drift unexpectedly.
  • Use a consistent Ruby version Replit uses the Ruby version specified in your .ruby-version file. Make sure it matches your Gemfile and what Rails expects.

    Example: \`\`\`text 3.2.2 \`\`\`
  • If you need to update Rails or other gems Update Gemfile, then run:

    \`\`\`shell bundle update rails \`\`\`
    or update all gems:

    \`\`\`shell bundle update \`\`\`
  • If gems fail to compile This is common with gems like pg, nokogiri, sqlite3, rmagick. The fix is almost always to install system headers:

    \`\`\`shell sudo apt-get install build-essential libpq-dev libsqlite3-dev \`\`\`
  • Run Rails using Bundler This ensures your app uses the installed gems:

    \`\`\`shell bundle exec rails s -b 0.0.0.0 \`\`\`

 

Common Replit-specific pitfalls

 

  • Not running bundle install after editing Gemfile Replit won't auto-install dependencies.
  • Missing system packages Many popular Rails gems need system libs; Replit behaves like a clean Linux server, not like macOS dev.
  • Using the wrong Ruby version Rails 7+ requires newer Rubies; mismatch causes gem install failures.
  • Deleting Gemfile.lock This causes environment drift and inconsistent installs between runs.
  • Expecting Rails assets to auto-build without Node If you use Rails asset pipeline or JS bundlers, install Node:

    \`\`\`shell sudo apt-get install nodejs \`\`\`

 

Practical working setup template for a Rails app on Replit

 

# Gemfile
ruby "3.2.2"

gem "rails", "~> 7.1"
gem "puma"
gem "pg"           // Needed if you're using PostgreSQL
gem "sass-rails"
gem "importmap-rails"
// Install dependencies
sudo apt-get update
sudo apt-get install -y build-essential libpq-dev nodejs

// Install gems
bundle install

// Run the app
bundle exec rails s -b 0.0.0.0

 

That’s the reliable, real-world way to manage Rails dependencies in Replit: keep Gemfile/Gemfile.lock clean, use bundler manually, install needed Linux packages, and keep Ruby version consistent. This mirrors real server environments, which is why it works so reliably on Replit.

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022