---
title: "Howto remove sprockets-rails from you Ruby on Rails project"
description: "Removing sprockets-rails from you modern Ruby on Rails project may reduce dependencies and simplify setup for your project."
url: "https://qameta.com/posts/howto-remove-sprockets-rails-from-your-ruby-on-rails-project/"
image: "https://qameta.com/images/posts/remove-sprockets-rails-from-ruby-on-rails.png"
---

# Howto remove sprockets-rails from you Ruby on Rails project

![Remove Sprockets from Ruby on Rails](https://qameta.com/images/posts/remove-sprockets-rails-from-ruby-on-rails.png)

Before removing [sprockets-rails](https://github.com/rails/sprockets-rails) from
dependencies of your [Ruby on Rails](https://rubyonrails.org) project, check
whether you are surfing images or fonts using sprockets through assets paths
like:

* app/assets/images
* app/assets/fonts

... or any other assets except [Style Sheets
(CSS)](https://en.wikipedia.org/wiki/Style_sheet_language):

* app/assets/js

If you are using
[cssbundling-rails](https://github.com/rails/cssbundling-rails/) the sprockets
default path for Style Sheets is used by default:

* app/assets/stylesheets

## Remove it after the replacement

Removing the good old sprockets from your modern [Ruby on
Rails](https://rubyonrails.org) project may be a useless step, as it won't stop
you from using modern alternatives like:

* [jsbundling-rails](https://github.com/rails/jsbundling-rails/)
* [cssbundling-rails](https://github.com/rails/cssbundling-rails/)
* [importmap-rails](https://github.com/rails/importmap-rails/)
* [webpacker(er)](https://github.com/rails/webpacker) is retired, see:
  [Move from webpack(er) to jsbundling-rails]()

But I try to reduce the number of gems, dependencies, and setups I have in our
projects. If it is not there, it won't bother you at all.

## Using cssbundling-rails and jsbundling-rails

If you want to move from webpacker to
[cssbundling-rails](https://github.com/rails/cssbundling-rails/) and
[jsbundling-rails](https://github.com/rails/jsbundling-rails/) these have a look
and my howtos:

* [Howto migrate from Webpacker to cssbundling-rails in Ruby on Rails for
  CSS](https://qameta.com/posts/howto-migrate-from-webpacker-to-cssbundling-rails-in-ruby-on-rails/)
* [Howto migrate from Webpacker to jsbundling-rails in Ruby on
  Rails](https://qameta.com/posts/howto-migrate-from-webpacker-to-jsbundling-rails-in-ruby-on-rails/)

They include also information, how to move you images from webpack(er) setup to
rails default assets pipeline. If you are on cssbundling-rails and
jsbundling-rails, stop here as these are using sprockets by default.

## Start by removing it from Gemfile

If you remove the gem from your *Gemfile* and run `bundle install` bundle should
remove it from your Gemfile.lock which will look like this in git:

```diff
diff --git a/Gemfile.lock b/Gemfile.lock
...
-    sprockets (4.1.1)
-      concurrent-ruby (~> 1.0)
-      rack (> 1, < 3)
-    sprockets-rails (3.4.2)
-      actionpack (>= 5.2)
-      activesupport (>= 5.2)
-      sprockets (>= 3.0.0)
```

You can also run bundle to remove the dependency:

```sh
./bin/bundle remove sprockets-rails
```

If you are using [sass-rails](https://rubygems.org/gems/sass-rails) then,
removing sprockets-rails from your setup won't have any effect. Just stop here
and undo your last changes.

This was the easy step as removing a dependency won't remove setup and
configuration for sprockets. You have to do it manually.

# Find and remove the basic setup from sprockets

After removing [sprockets-rails](https://github.com/rails/sprockets-rails) from
your project, you want to try to start it and see what happens.

The most common errors will be:

* An existing setup file (even empty): config/initializers/assets.rb
* Set options in the development environment file config/environments/development.rb

```diff
diff --git a/config/environments/development.rb b/config/environments/development.rb
...
   # Suppress logger output for asset requests.
-  config.assets.quiet = true
+  #config.assets.quiet = true
```

Just check the error message until you can start your project and everything is
working fine. Especially check for missing images, fonts, or other related stuff.

As you may have many different environments like *test*, *staging*, and
*development* grep for the word *assets*:

```sh
grep "assets" config/environments/*
```

It may be useful to try all the environments in a local setup before pushing the
branch to your git repository, which may trigger a *CI/CD system* to run *tests*
or even deploy to *staging* or even *production*.

## Summary

Previously sprockets were used for the whole asset pipeline and are still part
of the default ruby on rails setup. But depending on your setup (especially with
*webpack(er)*) you won't need it anymore.

Removing not needed dependencies and their setup is an essential part of
software development to reduce the complexity of a project.
