使用s3 gem + rails 4.1.5时,不允许使用`@@ {'作为类变量名(SyntaxError)

时间:2022-04-02 23:02:41

I know this type of question is already asked.

我知道这类问题已经被问到了。

I use s3 gem to upload my files in s3 bucket. But after s3 gem installation, when I start rails server it shows this error:

我使用s3 gem在s3存储桶中上传我的文件。但是在s3 gem安装之后,当我启动rails服务器时它会显示以下错误:

    /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223:in `class_eval': /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223: `@@{' is not allowed as a class variable name (SyntaxError)
/var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223: syntax error, unexpected $end
        unless defined? @@{:instance_writer=>true}
                          ^
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223:in `block in cattr_reader'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:222:in `each'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:222:in `cattr_reader'
    from /var/lib/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:258:in `cattr_accessor'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:155:in `<class:Store>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:154:in `<module:Cache>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:14:in `<module:ActiveSupport>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/cache.rb:12:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/jbuilder-2.2.5/lib/jbuilder/jbuilder_template.rb:3:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/jbuilder-2.2.5/lib/jbuilder/railtie.rb:2:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /var/lib/gems/1.9.1/gems/jbuilder-2.2.5/lib/jbuilder.rb:317:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
    from /var/lib/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
    from /home/rick/rick/Projects/practice/sharebox/config/application.rb:7:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `require'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:79:in `block in server'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `tap'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:76:in `server'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /var/lib/gems/1.9.1/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Does anyone know, how to solve this error? Should I try another gem?

有谁知道,如何解决这个错误?我应该尝试另一颗宝石吗?

2 个解决方案

#1


4  

Yeah i just ran into this issue and resolved. It is because AWS updated their gem to 2.0. If you update the gem to 2.0 different configuration is required according to this article they posted.

是的,我刚刚遇到这个问题并解决了。这是因为AWS将他们的gem更新为2.0。如果您将gem更新为2.0,则根据他们发布的这篇文章需要不同的配置。

If you want to using the version you had before, just change the Gemfile like below:

如果你想使用以前的版本,只需更改Gemfile如下:

Gemfile

gem 'aws-sdk', '< 2.0'

gem'aws-sdk','<2.0'

#2


1  

We had the same issue this morning. We already had this aws-sdk gem installed but it was updated to version 2 yesterday. It seems that version 2 doesn't fix this anymore so I advice to use last version 1 : 1.61.0

我们今天早上有同样的问题。我们已经安装了这个aws-sdk gem但它昨天更新到了版本2。似乎版本2不再解决这个问题所以我建议使用最新版本1:1.61.0

#1


4  

Yeah i just ran into this issue and resolved. It is because AWS updated their gem to 2.0. If you update the gem to 2.0 different configuration is required according to this article they posted.

是的,我刚刚遇到这个问题并解决了。这是因为AWS将他们的gem更新为2.0。如果您将gem更新为2.0,则根据他们发布的这篇文章需要不同的配置。

If you want to using the version you had before, just change the Gemfile like below:

如果你想使用以前的版本,只需更改Gemfile如下:

Gemfile

gem 'aws-sdk', '< 2.0'

gem'aws-sdk','<2.0'

#2


1  

We had the same issue this morning. We already had this aws-sdk gem installed but it was updated to version 2 yesterday. It seems that version 2 doesn't fix this anymore so I advice to use last version 1 : 1.61.0

我们今天早上有同样的问题。我们已经安装了这个aws-sdk gem但它昨天更新到了版本2。似乎版本2不再解决这个问题所以我建议使用最新版本1:1.61.0