Gemfile
Comprehensive Gemfile guide for Ruby bots and web (site/API) applications on Discloud.
🗂️ What is Gemfile
?
Gemfile
?Gemfile
lists the gems (libraries) your Ruby application needs. Discloud uses Bundler during deployment to install them before starting your app.
🛠️ Creating a Gemfile
(Quick Start)
Gemfile
(Quick Start)1
Initialize Bundler in an empty folder:
bundle init
This creates a starter Gemfile
.
2
Add dependencies directly via Bundler:
bundle add sinatra
bundle add puma
3
Install (respecting the Gemfile):
bundle install
🧪 Environment Groups
group :development, :test do
gem 'pry'
gem 'rspec'
end
group :production do
# production-only gems (APM, logging backends, etc.)
end
Skip installing dev/test groups at deploy time if desired:
bundle install --without development test
🧩 Example Gemfiles
source 'https://rubygems.org'
ruby '3.2.2'
gem 'rails', '~> 7.0.0'
gem 'puma', '~> 5.0'
gem 'pg', '~> 1.1' # or 'sqlite3' for simple/local usage
gem 'bootsnap', '>= 1.4.4', require: false
group :development, :test do
gem 'pry'
gem 'rspec-rails'
end
group :production do
# monitoring / caching / etc.
end
gem 'bundler', '~> 2.4'
🧾 Sample config.ru
(Sinatra / Rack Site)
config.ru
(Sinatra / Rack Site)require 'bundler/setup'
require 'sinatra'
require 'dotenv/load' if ENV['RACK_ENV'] != 'production'
set :bind, '0.0.0.0'
set :port, (ENV['PORT'] || 8080)
get '/' do
'Hello from Discloud Sinatra app!'
end
run Sinatra::Application
For bots you typically do NOT need config.ru
; instead just point MAIN
in discloud.config
to your Ruby entry (e.g. bot.rb
).
🧪 Updating Dependencies
# Update a single gem
bundle update puma
# Update all (careful – may introduce breaking changes)
bundle update
# See outdated gems
bundle outdated
Security patches: monitor advisories (e.g., RubySec / Dependabot) and schedule periodic bundle update --patch
.
🧰 Common Commands Reference
# Initialize Gemfile
bundle init
# Add gem (writes Gemfile & installs)
bundle add <gem>
# Install with production-only groups
bundle install --without development test
# Check dependency graph issues
bundle check
# Clean unused gems (after prune)
bundle clean --force
Last updated