Running Rails on Replit
Learn how to set up and run Ruby on Rails applications on Replit, including importing from GitHub, configuring hosts, and troubleshooting common issues.
This guide helps with the steps to run a Ruby on Rails application on Replit. If you are starting from scratch, it is recommended that you use the existing Ruby on Rails template.
Starting from an existing GitHub repository
If you already have a Rails application stored in a GitHub repository and want to clone the repository into Replit, you’ll need to do the following things:
- From the main menu, start by creating a Replit App and importing your repository from GitHub. After you select Import from GitHub and cloning the repository, you will select the run command. If Replit detects your imported repository as a Rails application, it will automatically supply you with the appropriate run command. If not, for rails applications, use the following run command:
- he app should be bound to
0.0.0.0
instead oflocalhost
to be able to run on Replit. - The command is prefaced with
bundle exec
to run in the context of the installed gems. Any Rails commands you run must be prefaced withbundle exec
. - Once the run command is set, you will likely also need to install all the existing necessary packages by running the following command in the shell:
- Once that is done, use the run button to run the application.
However, to fully utilize Replit’s features, you must make two more changes.
- Allow
*.replit.dev
hosts by adding the following line toconfig/environments/development.rb
.
- Then, allow the app to be iframed on
replit.com
by adding the following lines toconfig/application.rb
.
- Now, when you run your app, a window should pop up displaying your application.
Running Commands
All commands must be prefaced by bundle exec
. This ensures that the command runs in the context of the installed gems environment. The console pane will give you output from the server, but you can run arbitrary commands from the shell without stopping the server.
FAQ
Could not find the ‘bundler’ required by your ‘Gemfile.lock’
The version of the bundler that your lock file requires is not the one we currently have on Replit. You can either install the appropriate version of the bundler or delete the Gemfile.lock
and then run bundle install
to reinstall the correct version of the necessary packages and also recreate the lock file.
Was this page helpful?