PmRails is a toolset for testing or developing Ruby on Rails applications without installing Rails or its dependencies into your local environment. It leverages Podman to create an isolated, containerized environment for your Rails projects.
- Clean Local Environment: No need to install Rails or dependencies locally.
- Quick Setup: Start developing immediately if Podman is installed.
- Consistent and Reproducible Environments: Isolated containers prevent dependency conflicts, making it ideal for team collaboration.
- Experiment Freely: Safely test different Rails versions or configurations.
PmRails provides the following commands:
-
pmrails
: Runs Rails commands as a wrapper forbin/rails
.
Usage:pmrails COMMAND [OPTIONS]
-
pmrails-new
: Creates a new Rails application as a wrapper forbin/rails new
.
Usage:pmrails-new RAILS_VERSION APP_PATH [OPTIONS]
-
pmrailsenvexec
: Executes arbitrary commands within the containerized environment.
Usage:pmrailsenvexec COMMAND [OPTIONS]
-
pmbundle
: Manages gems as a wrapper forbundle
.
Usage:pmbundle [BUNDLE_ARGS]
Gems are installed into thevendor/bundle/
directory, which is used bypmrails
.
To reset the gem environment, simply delete the vendor/bundle/
directory:
rm -rf vendor/bundle/
Follow the Podman Installation Instructions for your operating system.
Download PmRails to your preferred location. For example:
mkdir -p ~/.var
cd ~/.var
git clone https://github.com/wakairo/pmrails.git
Add the bin
directory to your system's PATH environment variable. For example, using bash:
echo 'export PATH="$HOME/.var/pmrails/bin/:$PATH"' >> ~/.bashrc
exec $SHELL -l
Navigate to a temporary directory. For example:
mkdir -p ~/tmp
cd ~/tmp
Create a new Rails app using the desired Rails version:
pmrails-new 8.0.1 sample_app --skip-bundle
Move to the application directory:
cd sample_app
Run Bundler to install Gems:
pmbundle install
If using Git for your app, add /vendor/bundle/
to .gitignore
. For example:
echo /vendor/bundle/ >> .gitignore
To run Rails commands, use pmrails. For example, to start the server:
pmrails server -b 0.0.0.0
Then, open your web browser and navigate to http://localhost:3000/
.
More Examples:
# Run database migrations
pmrails db:migrate
# Execute tests
pmrails test
# Open the Rails console
pmrails console
# Run the Rails setup script
pmrailsenvexec bin/setup