LoginSignup
2
3

More than 1 year has passed since last update.

【エラー解決方法】devise_token_authエラー(Rails7)の対応について

Last updated at Posted at 2022-09-09

エラー内容

gem 'devise'
gem 'devise_token_auth'

Gemfileに上記の2つを追加して

$ bundle

を実行すると

Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies....
Bundler could not find compatible versions for gem "rails":
  In snapshot (Gemfile.lock):
    rails (= 7.0.3.1)

  In Gemfile:
    rails (~> 7.0.3, >= 7.0.3.1)

    devise_token_auth was resolved to 0.1.21.alpha2, which depends on
      rails (~> 4.1.4)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

解決方法

方法は以下の2通り
1.device_token_authを使えるようにrailsのバージョンを下げる

2.device_token_authの代わりになるgemを使用する

今回はrailsのバージョンを下げたくないので、2を採用

Gemfileに以下のようにdevise_token_authを追加する

gem 'devise_token_auth', '>= 1.2.0', git: "https://github.com/lynndylanhurley/devise_token_auth"

補足

  • rubygemsに上がっているdevise_token_authがRails7をサポートしていないためインストールができない
  • githubに上がっているdevise_token_authはRails7をサポートしているので、インストール出来る
  • 1を採用する場合は以下の記事を参考にしてみてください
    https://qiita.com/sssssatou/items/054006c3fed544a7aebc
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3