How to Setup Ruby to run gem install Without Sudo

I wrote these tutorials for myself in future when I forget for the next steps.
Search for a command to run...

I wrote these tutorials for myself in future when I forget for the next steps.
No comments yet. Be the first to comment.
When you provision an Ubuntu instance on Oracle Cloud, you'll notice something different from standard Ubuntu installations: the system uses iptables instead of ufw for firewall management. This disti

When developing web applications locally, HTTPS is often overlooked. Yet, modern browsers and APIs increasingly require secure connections—even in development. That’s where mkcert comes in: a simple t

Testing the checkout success page in Magento 2 can be frustrating. By default, once an order is placed, Magento clears the quote session, meaning you can’t simply refresh or revisit the success page without going through the entire checkout process a...

Magento Commerce (EE) offers powerful features, but for many teams, Open Source (CE) is leaner, lighter, and more sustainable. If you're migrating from EE to CE, the Opengento downgrade tool provides a clean, scriptable way to remove proprietary modu...

If you’ve ever checked your Apache error logs and seen something like this: Code [core:error] (13)Permission denied: access to /robots.txt denied (filesystem path '/home/username/sites') because search permissions are missing on a component of the pa...

let’s get you a clean Ruby environment so you can install Capistrano without sudo and without fighting system directories. The easiest, safest way is to use a Ruby version manager like rbenv (lightweight) or rvm (full‑featured). I’ll walk you through rbenv since it’s simple and works well on Linux/Ubuntu/Debian.
bash
# Install dependencies
sudo apt update
sudo apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev git
# Clone rbenv into ~/.rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
# Add rbenv to PATH and init in your shell
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
source ~/.bashrc
# Install ruby-build plugin
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
bash
# List available Ruby versions
rbenv install -l
# Install a stable version (e.g., 3.4.5)
rbenv install 3.4.5
# Set it as default
rbenv global 3.4.5.
bash
gem install capistrano
bash
ruby -v
gem -v
cap --version
You should now see:
Ruby version from rbenv (not system Ruby)
Capistrano installed and runnable without sudo
💡 Why this works rbenv installs Ruby entirely in your home directory (~/.rbenv), so you own the files and can install/update gems freely. No system paths, no permission errors.