There are a few things to note here:
- It's safer to specify maximum versions to update to in your Gemfile
- Your session is not deserializing correctly - this is the cause of the exception you're seeing
- If you're having trouble with a single gem and need to update, use
bundle update <gem name>
Specify maximum Gem versions
You should get into the practice of using the pessimistic version constraint (the ~>
operator) in your Gemfile. This essentially allows you to say that gems can only be updated to higher patch levels.
Ruby developers tend to use the standard of version numbers with three numbers: x.x.x, e.g. 2.0.1. The first number is the major version, the second number the minor version and the third number is the patch.
Major version updates are likely to break old functionality. If you upgrade from 1.x.x to 2.x.x, it could be a painful process. Minor version updates should add features and, in rare cases, change existing functionality, but it should be backwards compatible. Patch level updates should be purely bug fixes.
The pessimistic version constraint can be used to say "only allow patch level updates". For example:
gem 'devise', '~> 2.2.3' # Only the '.3' can increase, e.g. 2.2.4, 2.2.5
If you do this for all of your gems then you can be reasonably sure that bundle update
will update gems to compatible versions. In your Gemfile you have
gem 'devise', '>= 2.2.3'
This would potentially allow the installation of devise 3.0.0, which you can almost guarantee would be problematic.
It's good practice to find a gem configuration that works, then use the pessimistic version constraint to lock your Gemfile down to only patch level updates.
Session deserialization
It looks like devise has been updated, which has caused a session deserialization problem. You could check out an old version of your Gemfile.lock
, then downgrade to the devise version that was working. Or you could just clear your cache if you don't have anything critical in the session and use the new version.
Update a single gem
Running bundle update
will attempt to update all gems in your Gemfile. If you only need to update a single gem, use bundle update <gem name>
. All the others will remain at the same version.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…