【问题标题】:Why is `rake assets:precompile` throwing "getaddrinfo: Name or service not known"? (re: asset_sync)为什么`rake assets:precompile` 会抛出“getaddrinfo: Name or service not known”? (回复:asset_sync)
【发布时间】:2012-08-01 17:12:54
【问题描述】:

我正在尝试设置我的 rails 应用程序以使用 asset_sync gem 将其资产上传到亚马逊的 AWS S3,遵循 these instructions。我知道我的 S3 配置正确,因为我的应用程序能够将图像上传到 S3。我很确定我的所有设置都是正确的:

FOG_DIRECTORY => mybucketname
FOG_PROVIDER  => AWS
FOG_REGION    => s3-us-west-2

但我不断收到错误:

-bash> heroku run rake assets:precompile --remote staging
Running rake assets:precompile attached to terminal... up, run.1
AssetSync: using default configuration from built-in initializer
mkdir -p /app/public/assets
...
mkdir -p /app/public/assets
AssetSync: Syncing.
rake aborted!
getaddrinfo: Name or service not known                                # <-- error

在本地编译会产生稍微不同的错误:

-bash> bundle exec rake assets:precompile
AssetSync: using default configuration from built-in initializer
mkdir -p /Users/bart/Dev/MyApp/myapp/public/assets
...
mkdir -p /Users/bart/Dev/MyApp/myapp/public/assets
AssetSync: Syncing.
rake aborted!
getaddrinfo: nodename nor servname provided, or not known             # <-- error

【问题讨论】:

    标签: ruby-on-rails amazon-s3 asset-pipeline cdn fog


    【解决方案1】:

    我将错误追溯到a 'connection' line in Fog,这是asset_sync 的运行时依赖项之一,结果发现我的FOG_REGION 设置不正确。就我而言,该区域应该是us-west-2,而不是s3-us-west-2

    我已经有一段时间没有配置我的 S3 账户了,所以我首先尝试通过登录 AWS S3 控制台,单击存储桶名称,然后单击“属性”来确定我正在使用的区域。在那里,该地区被列为俄勒冈州。好吧,那没有用。因此,我点击了现有存储桶之一的对象和文件夹浏览器,直到找到资产,查看其“属性”,并看到“链接”:

    https://s3-us-west-2.amazonaws.com/mybucketname/uploads/mymodel/image/1135/myimage.jpg

    我确信s3-us-west-2 是正确的,直到我注意到Fog adds the s3- prefix

    无论如何,我现在知道,一旦您通过名称找到您所在的地区(例如俄勒冈州),您可以在 this list of S3 regions 中查找它(它是 Location Constraint 列下的名称)。

    我希望这对某人有所帮助。

    【讨论】:

    • 很好的答案。还是不明白为什么亚马逊这么大的公司,UI 很差
    猜你喜欢
    • 2014-03-22
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 2011-02-06
    • 2019-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多