Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

4.5 KB
Raw Blame
---
title: 4.1 to 4.2
section: upgrades
order: 0
description: This guide covers upgrading a 4.1 Spree application to Spree 4.2.
canonical: "https://spreecommerce.org/docs/v5/developer/upgrades/4.1-to-4.2"
---


<Note>
If you're on an older version than 4.1 please follow previous upgrade guides and perform those upgrades incrementally, eg.

1. [upgrade 3.7 to 4.0](3.7-to-4.0)
2. [upgrade 4.0 to 4.1](4.0-to-4.1)
</Note>

## Update gems

Run the following command to update your gems to 4.2:

```bash
bundle update
```

## Remove SpreeMultiCurrency optional

If you used that gem in the past you need to remove it. Multi-Currency is now incorporated into Spree core and you cannot use that gem anymore.

1. Remove `spree_multi_currency` from your `Gemfile`

   ```bash
   bundle remove spree_multi_currency
   ```

2. Remove these preferences from your Spree initializer `config/initializers/spree.rb`:
   * `allow_currency_change`
   * `show_currency_selector`
   * `supported_currencies`
3. Remove `//= require spree/frontend/spree_multi_currency` from `vendor/assets/javascripts/spree/frontend/all.js`
4. Remove `//= require spree/backend/spree_multi_currency` from `vendor/assets/javascripts/spree/backend/all.js`

## Optional Remove SpreeI18n config

All international configuration is now kept on the `Store` model in the database rather than in initializer files.

If you used `spree_i18n` gem before please remove any `SpreeI18n::Config` references from your `config/initializers/spree.rb` file.

## Optional Add `deface` gem

If you used [Deface overrides](../../advanced/deface_overrides_tutorial#organizing-overrides) you will need to include `deface` in your `Gemfile` as it was removed from Spree / Spree Auth Devise / Spree Gateway dependencies.

```bash
bundle add deface
```

## Fix RMA migration

Please find a `add_stock_location_to_rma` migration in your `db/migrate` directory and change:

```ruby
class AddStockLocationToRma < ActiveRecord::Migration[4.2]
```

to

```ruby
class AddStockLocationToRMA < ActiveRecord::Migration[4.2]
```

## Install missing migrations

```bash
bin/rake spree:install:migrations
```

## Run migrations

```bash
bin/rails db:migrate
```

## Other things to remember

### Replace `fast_json` with `jsonapi-serializer`

Please follow [this guide to migrate your custom serializers](https://github.com/jsonapi-serializer/jsonapi-serializer#migrating-from-netflixfast_jsonapi).

### Migrate select2 3.5 to 4

Only if you've added new Admin Panel pages with Select2 dropdown - [this guide will help](https://select2.org/upgrading/migrating-from-35)

### Make sure you've got up to date Spree templates Storefront

If you're using Spree default Storefront `spree_frontend` gem make sure to update your templates, especially:

* [app/views/spree/shared/_head.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_head.html.erb)
* [app/views/spree/shared/_locale_and_currency.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_locale_and_currency.html.erb)
* [app/views/spree/shared/_link_to_account.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_link_to_account.html.erb)
* [app/views/spree/shared/_internationalization_options.html.erb](https://github.com/spree/spree/blob/main/frontend/app/views/spree/shared/_internationalization_options.html.erb)
* [app/views/spree/shared/_locale_dropdown.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_locale_dropdown.html.erb)
* [app/views/spree/shared/_currency_dropdown.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_currency_dropdown.html.erb)
* [app/views/spree/shared/_mobile_navigation.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_mobile_navigation.html.erb)
* [app/views/spree/shared/_mobile_internationalization_options.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_mobile_internationalization_options.html.erb)
* [app/views/spree/shared/_nav_bar.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_nav_bar.html.erb)
* [app/views/spree/shared/_line_item.html.erb](https://github.com/spree/spree/blob/4-2-stable/frontend/app/views/spree/shared/_line_item.html.erb)

Or simply run `bin/rails g spree:frontend:copy_storefront`

## Read the release notes

For information about changes contained within this release, please read the [4.2.0 Release Notes](https://github.com/spree/spree/releases/tag/v4.2.0).

## More info