简体   繁体   English

好像未安装AWS红宝石gem

[英]AWS ruby gem as if is not installed

When I try to run a really small program that was nly suposed to test if I can connect to the amazon dynamoDB I get an error as if I havent installed the aws gem... 当我尝试运行一个很小的程序以测试是否可以连接到亚马逊dynamoDB时,出现错误,好像我没有安装aws gem。

My code is the following: 我的代码如下:

require "AWS"

AWS.config(  access_key_id: ENV["coco"],
secret_access_key: ENV["xixi"]
)

DB = AWS::DynamoDB.new

And I have the following error: 而且我有以下错误:

 reducer.rb:4:in `<main>': uninitialized constant AWS (NameError)

The gem is installed as you can see here: 您可以在此处看到gem的安装:

Bernardos-MacBook-Pro:cn bersimoes$ gem which aws
/Users/bersimoes/.rvm/gems/ruby-1.9.3-p286/gems/aws-2.6.0/lib/aws.rb

Any help is appreciated! 任何帮助表示赞赏!

You've got the wrong gem. 您有错误的宝石。 You want aws-sdk for AWS::DynamoDB support . 您需要aws-sdk以获得AWS::DynamoDB支持 Install with: 安装方式:

gem install aws-sdk

You might need to uninstall the existing aws gem to ensure you load the right one (they both have an aws.rb file). 您可能需要卸载现有的aws gem,以确保加载正确的aws gem(它们都有一个aws.rb文件)。 Alternatively you could use gem 'aws-sdk' in your code before your require to ensure the correct gem is loaded. 另外,您可以在require确保已加载正确的gem之前在代码中使用gem 'aws-sdk' Another possibility is to require 'aws-sdk' since the gem provides that file basically as an alias . 另一种可能是require 'aws-sdk'因为gem 基本上是将该文件提供为别名

Also you should use: 另外,您应该使用:

require 'aws' # note lower case

This probably won't cause problems on a Mac, but will cause issues if you ever move your code to a case-sensitive machine like Linux. 在Mac上,这可能不会引起问题,但是如果您将代码移至区分大小写的机器(如Linux),则会引起问题。

If you are receiving this error and you have the "aws-sdk" gem installed, you likely have upgraded to version 2 of the aws-sdk gem unintentionally . 如果您收到此错误,并且安装了“ aws-sdk” gem,则可能无意中升级到aws-sdk gem的版本2 Version 2 uses the Aws namespace, not AWS . 版本2使用Aws命名空间,而不使用AWS This allows version 1 and version 2 to be used in the same application. 这允许版本1和版本2在同一应用程序中使用。

See this blog post for more information. 有关更多信息,请参见此博客文章

Yeah i just ran into this issue and resolved. 是的,我刚遇到这个问题并解决了。 It is because AWS updated their gem to 2.0. 这是因为AWS将其gem更新为2.0。 If you update the gem to 2.0 different configuration is required according to this article they posted. 如果您将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' 宝石'aws-sdk','<2.0'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM