我最近跑了一个bundle update
,现在我得到了一个奇怪的
Type - [17] is not a symbol
错误。
这是完整的错误消息:
Started GET "/" for 127.0.0.1 at 2013-05-14 03:46:35 -0500
TypeError - [17] is not a symbol:
(gem) activesupport-3.2.13/lib/active_support/inflector/methods.rb:230:in `block in constantize'
(gem) activesupport-3.2.13/lib/active_support/inflector/methods.rb:229:in `constantize'
(gem) devise-2.2.3/lib/devise/rails/warden_compat.rb:27:in `deserialize'
(gem) warden-1.2.1/lib/warden/session_serializer.rb:35:in `fetch'
(gem) warden-1.2.1/lib/warden/proxy.rb:212:in `user'
(gem) warden-1.2.1/lib/warden/proxy.rb:318:in `_perform_authentication'
(gem) warden-1.2.1/lib/warden/proxy.rb:104:in `authenticate'
(gem) warden-1.2.1/lib/warden/proxy.rb:114:in `authenticate?'
(gem) devise-2.2.3/lib/devise/rails/routes.rb:286:in `block in authenticated'
(gem) actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:31:in `block in matches?'
(gem) actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:28:in `matches?'
(gem) actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:42:in `call'
(gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
(gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
(gem) rack-pjax-0.7.0/lib/rack/pjax.rb:12:in `call'
(gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/error_collector.rb:12:in `call'
(gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/agent_hooks.rb:18:in `call'
(gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/browser_monitoring.rb:16:in `call'
(gem) bullet-4.6.0/lib/bullet/rack.rb:10:in `call'
(gem) meta_request-0.2.3/lib/meta_request/middlewares/app_request_handler.rb:11:in `call'
(gem) rack-contrib-1.1.0/lib/rack/contrib/response_headers.rb:17:in `call'
(gem) meta_request-0.2.3/lib/meta_request/middlewares/headers.rb:16:in `call'
(gem) meta_request-0.2.3/lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
(gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
(gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
(gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
(gem) rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call'
(gem) remotipart-1.0.5/lib/remotipart/middleware.rb:30:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call'
(gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
(gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call'
(gem) activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call'
(gem) activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
(gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__1566733404690363964__call__3169664716453937753__callbacks'
(gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
(gem) activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
(gem) activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:65:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
(gem) better_errors-0.8.0/lib/better_errors/middleware.rb:84:in `protected_app_call'
(gem) better_errors-0.8.0/lib/better_errors/middleware.rb:79:in `better_errors_call'
(gem) better_errors-0.8.0/lib/better_errors/middleware.rb:56:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
(gem) railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app'
(gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call'
(gem) activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged'
(gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `call'
(gem) quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call'
(gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
(gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call'
(gem) activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
(gem) rack-1.4.5/lib/rack/lock.rb:15:in `call'
(gem) actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call'
(gem) railties-3.2.13/lib/rails/engine.rb:479:in `call'
(gem) railties-3.2.13/lib/rails/application.rb:223:in `call'
(gem) rack-1.4.5/lib/rack/content_length.rb:14:in `call'
(gem) railties-3.2.13/lib/rails/rack/log_tailer.rb:17:in `call'
(gem) thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
(gem) thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
(gem) thin-1.5.1/lib/thin/connection.rb:54:in `process'
(gem) thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
(gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
(gem) thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
(gem) thin-1.5.1/lib/thin/server.rb:159:in `start'
(gem) rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
(gem) rack-1.4.5/lib/rack/server.rb:268:in `start'
(gem) railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
(gem) railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
(gem) railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `<main>'
我完全不知道可能会突然造成什么。
不知道这是否有帮助,但这是我的Gemfile.lock
:
GIT
remote: git://github.com/ctran/annotate_models.git
revision: 8bd159c7a484093fde84beaa9e6398f25ddacf09
specs:
annotate (2.6.0.beta1)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
active_utils (1.0.5)
activesupport (>= 2.3.11)
i18n
activemerchant (1.32.1)
active_utils (>= 1.0.2)
activesupport (>= 2.3.14)
builder (>= 2.0.0)
i18n
json (>= 1.5.1)
money
nokogiri
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
acts-as-taggable-on (2.4.1)
rails (>= 3, < 5)
addressable (2.3.4)
arel (3.0.2)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
multi_json (>= 1.0.0)
bcrypt-ruby (3.0.1)
better_errors (0.8.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.1)
debug_inspector (>= 0.0.1)
bootstrap-sass (2.3.1.0)
sass (~> 3.2)
bootstrap-wysihtml5-rails (0.3.1.19)
railties (>= 3.0)
builder (3.0.4)
bullet (4.6.0)
uniform_notifier
cancan (1.6.9)
carrierwave (0.8.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.2)
countries (0.9.2)
currencies (>= 0.4.0)
currencies (0.4.0)
daemons (1.1.9)
database_cleaner (1.0.0.RC1)
debug_inspector (0.0.2)
devise (2.2.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.2.4)
email_spec (1.4.0)
launchy (~> 2.1)
mail (~> 2.2)
erubis (2.7.0)
eventmachine (1.0.3)
excon (0.21.0)
execjs (1.4.0)
multi_json (~> 1.0)
extlib (0.9.16)
faraday (0.8.7)
multipart-post (~> 1.1)
fog (1.11.0)
builder
excon (~> 0.20)
formatador (~> 0.2.0)
google-api-client (~> 0.6.2)
json (~> 1.7)
mime-types
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5.0)
ruby-hmac
font-awesome-sass-rails (3.0.2.2)
railties (>= 3.1.1)
sass-rails (>= 3.1.1)
formatador (0.2.4)
friendly_id (4.0.9)
google-api-client (0.6.3)
addressable (>= 2.3.2)
autoparse (>= 0.3.3)
extlib (>= 0.9.15)
faraday (~> 0.8.4)
jwt (>= 0.1.5)
launchy (>= 2.1.1)
multi_json (>= 1.0.0)
signet (>= 0.4.4)
uuidtools (>= 2.1.0)
haml (4.0.2)
tilt
hike (1.2.2)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.2.1)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (3.0.1)
jquery-rails
railties (>= 3.1.0)
json (1.7.7)
jwt (0.1.8)
multi_json (>= 1.5)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
launchy (2.3.0)
addressable (~> 2.3)
letter_opener (1.0.0)
launchy (>= 2.0.4)
libv8 (3.11.8.17)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta_request (0.2.3)
rack-contrib
railties
mime-types (1.23)
mini_magick (3.5.0)
subexec (~> 0.2.1)
money (5.1.1)
i18n (~> 0.6.0)
multi_json (1.7.2)
multipart-post (1.2.0)
nested_form (0.3.2)
net-scp (1.1.0)
net-ssh (>= 2.6.5)
net-ssh (2.6.7)
newrelic_rpm (3.6.1.88)
nokogiri (1.5.9)
orm_adapter (0.4.0)
pg (0.15.1)
piggybak (0.6.30)
activemerchant
countries
devise
rack-ssl-enforcer
rails (~> 3.2.8)
rails_admin (~> 0.4.5)
piggybak_bundle_discounts (0.0.5)
rails (~> 3.2.8)
piggybak_stripe (0.0.2)
stripe (= 1.7.4)
piggybak_variants (0.0.17)
rails (~> 3.2.3)
polyglot (0.3.3)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-contrib (1.1.0)
rack (>= 0.9.1)
rack-pjax (0.7.0)
nokogiri (~> 1.5)
rack (~> 1.3)
rack-ssl (1.3.3)
rack
rack-ssl-enforcer (0.2.5)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
rails_admin (0.4.7)
bootstrap-sass (~> 2.2)
builder (~> 3.0)
coffee-rails (~> 3.1)
font-awesome-sass-rails (~> 3.0, >= 3.0.0.1)
haml (~> 4.0)
jquery-rails (~> 2.1)
jquery-ui-rails (~> 3.0)
kaminari (~> 0.14)
nested_form (~> 0.3)
rack-pjax (~> 0.6)
rails (~> 3.1)
remotipart (~> 1.0)
safe_yaml (~> 0.6)
sass-rails (~> 3.1)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.4)
remotipart (1.0.5)
rest-client (1.6.7)
mime-types (>= 1.16)
rmagick (2.13.2)
rolify (3.2.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1)
rspec-rails (2.13.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
ruby-hmac (0.4.0)
safe_yaml (0.9.1)
sass (3.2.8)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sendgrid (1.1.0)
json
json
sextant (0.2.3)
activesupport (>= 3.2)
rails (>= 3.2)
signet (0.4.5)
addressable (>= 2.2.3)
faraday (~> 0.8.1)
jwt (>= 0.1.5)
multi_json (>= 1.0.0)
simple_form (2.1.0)
actionpack (~> 3.0)
activemodel (~> 3.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
stripe (1.7.4)
multi_json (~> 1.1)
rest-client (~> 1.4)
subexec (0.2.3)
therubyracer (0.11.4)
libv8 (~> 3.11.8.12)
ref
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.18.1)
tilt (1.4.0)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
uglifier (2.0.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
uniform_notifier (1.2.0)
uuidtools (2.1.4)
warden (1.2.1)
rack (>= 1.0)
PLATFORMS
ruby
DEPENDENCIES
acts-as-taggable-on
annotate!
better_errors (>= 0.7.2)
binding_of_caller (>= 0.7.1)
bootstrap-sass (>= 2.3.0.0)
bootstrap-wysihtml5-rails
bullet
cancan (>= 1.6.9)
carrierwave
coffee-rails (~> 3.2.1)
database_cleaner (>= 1.0.0.RC1)
devise (>= 2.2.3)
email_spec (>= 1.4.0)
execjs
fog
font-awesome-sass-rails
friendly_id
jquery-rails
letter_opener
meta_request
mini_magick
newrelic_rpm
pg (>= 0.15.0)
piggybak
piggybak_bundle_discounts
piggybak_stripe
piggybak_variants
quiet_assets (>= 1.0.2)
rails (= 3.2.13)
rails_admin
rmagick
rolify (>= 3.2.0)
rspec-rails (>= 2.12.2)
sass-rails (~> 3.2.3)
sendgrid (>= 1.0.1)
sextant
simple_form (>= 2.1.0)
therubyracer
thin (>= 1.5.0)
uglifier (>= 1.0.3)
修改1
这是我的Gemfile
:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
group :development do
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
gem 'sextant'
gem "quiet_assets", ">= 1.0.2"
gem "better_errors", ">= 0.7.2"
gem "binding_of_caller", ">= 0.7.1"
gem 'meta_request'
gem 'execjs'
gem 'therubyracer'
gem "letter_opener"
gem 'bullet'
# gem 'rack-mini-profiler'
end
group :test do
gem "database_cleaner", ">= 1.0.0.RC1"
gem "email_spec", ">= 1.4.0"
end
group :development, :test do
gem "rspec-rails", ">= 2.12.2"
end
gem 'jquery-rails'
gem "thin", ">= 1.5.0"
gem "pg", ">= 0.15.0"
gem "font-awesome-sass-rails"
gem "bootstrap-sass", ">= 2.3.0.0"
gem "bootstrap-wysihtml5-rails"
gem "bootstrap-sass", ">= 2.3.0.0"
gem "sendgrid", ">= 1.0.1"
gem "devise", ">= 2.2.3"
gem "cancan", ">= 1.6.9"
gem "rolify", ">= 3.2.0"
gem "simple_form", ">= 2.1.0"
gem "newrelic_rpm"
gem "rmagick"
gem "mini_magick"
gem "carrierwave"
gem "fog"
gem "piggybak"
gem "piggybak_variants"
gem "piggybak_bundle_discounts"
gem "rails_admin"
gem "acts-as-taggable-on"
gem "friendly_id"
gem "piggybak_stripe"
答案 0 :(得分:7)
这里有几点需要注意:
bundle update <gem name>
您应该在Gemfile中使用pessimistic version constraint(~>
运算符)。这基本上允许您说宝石只能更新到更高的补丁级别。
Ruby开发人员倾向于使用具有三个数字的版本号标准: x.x.x ,例如 2.0.1 。第一个数字是主要版本,第二个数字是次要版本,第三个数字是补丁。
主要版本更新可能会破坏旧功能。如果从 1.x.x 升级到 2.x.x ,则可能是一个痛苦的过程。次要版本更新应添加功能,在极少数情况下,更改现有功能,但应向后兼容。补丁级别更新应该是纯粹的错误修复。
悲观版本约束可用于表示“仅允许补丁级别更新”。例如:
gem 'devise', '~> 2.2.3' # Only the '.3' can increase, e.g. 2.2.4, 2.2.5
如果您为所有宝石执行此操作,那么您可以合理地确定bundle update
会将宝石更新为兼容版本。在你的Gemfile中你有
gem 'devise', '>= 2.2.3'
这可能会允许安装设备 3.0.0 ,你几乎可以保证这会有问题。
最好找到有效的gem配置,然后使用悲观版本约束将Gemfile锁定为仅补丁级更新。
看起来设计已经更新,这导致会话反序列化问题。您可以查看旧版Gemfile.lock
,然后降级到正在运行的设计版本。或者,如果您在会话中没有任何关键内容并使用新版本,则可以清除缓存。
运行bundle update
将尝试更新Gemfile中的所有gem。如果您只需要更新单个gem,请使用bundle update <gem name>
。所有其他人将保持相同的版本。
答案 1 :(得分:5)
这个问题是很久以前发布的,所以我想原来的人不再需要答案了。但是,像我这样的人可能迫切需要一个答案,而不是炸毁所有的争吵。这是原因和我的解决方案: Devise 2.2.4具有向后不兼容的更改,会破坏所有现有会话。请参阅2.2.4的更改日志 https://github.com/plataformatec/devise/blob/master/CHANGELOG.md
devise&lt; = 2.2.3无法正确处理由devise&gt; = 2.2.4创建的会话。
问题来自使用的会话密钥设计。假设你已经设计了你的玩家模型。对于设计&lt; = 2.2.3,会话在会话中具有以下内容
session["warden.user.player.key']=["Player", [player_id], "somehashhere"]
对于设计&gt; = 2.2.4,会话变为以下
session["warden.user.player.key']=[[player_id], "somehashhere"]
我认为设计作者不喜欢“播放器”,因为它已经在许多不同的地方以及密钥本身中指定。这是一个合理的更改,新代码确实正确处理升级,因为它可以理解旧会话并保持您的优秀会话活跃。
但这只能解决升级问题,而不是降级。如果您将设备升级到2.2.4,登录然后降级到2.2.3,您将看到如下错误。显然在设计代码(&lt; 2.2.3)的某处,它将'Play'转换为symbol:user。但是'用户'不再存在,而且你有一个'非符号'的错误。
仅当您使用数据库存储进行会话时,才将页面指向解决方案。您需要进行迁移 https://gist.github.com/moll/6417606
如果您使用cookie存储存储(长时间默认使用rails),那么当您从更高版本的设备降级时,需要将以下代码添加到应用程序控制器
before_filter :fix_session
def fix_session
key = session["warden.user.player.key"]
if key && key.is_a?(Array) && key[0].is_a?(Array)
session["warden.user.player.key"].unshift('Player')
end
end
至于降级的原因?如果您确定一切正常并且您永远不必回滚那么这不是问题。但如果你不太确定,你就需要这个。
答案 2 :(得分:2)
我将我的Gemfile更新为gem "devise", ">= 2.2.4"
,然后删除了我的Gemfile.lock
并通过执行bundle install
重新创建了它。
无论出于何种原因,这似乎解决了这个特殊问题。
我不能肯定地说,虽然它是由那个版本的Devise引起的。它可能是另一个更新的宝石 - 但这是我所做的唯一改变。
所以拿出一粒盐。