ruby-on-rails - `/home/webapp` 不是目录 - Elastic Beanstalk (RAILS)

标签 ruby-on-rails ruby amazon-web-services ruby-on-rails-5 amazon-elastic-beanstalk

我正在尝试将 Rails 5 应用程序部署到 Elastic Beanstalk,但我在日志文件中收到以下错误,似乎表明我的主目录设置不正确。

我尝试通过将 HOME 设置为 ~/my-app-name 来设置 HOME 环境变量,但我没有运气,它无论如何似乎都没有使用该变量。我在环境配置的软件部分下设置了变量。

/var/log/eb-activity.log:

+ cd /var/app/ondeck
+ su -s /bin/bash -c 'bundle exec 
/opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb assets:precompile' webapp
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
+ '[' false == true ']'
+ su -s /bin/bash -c 'bundle exec rake assets:precompile' webapp
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
rake aborted!
Psych::SyntaxError: (<unknown>): did not find expected alphabetic or numeric 
character while scanning an alias at line 83 column 22
/var/app/ondeck/config/environments/production.rb:96:in `block in <top (required)>'
/var/app/ondeck/config/environments/production.rb:1:in `<top (required)>'
/var/app/ondeck/config/environment.rb:5:in `<top (required)>'
/opt/rubies/ruby-2.5.3/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.3/bin/bundle:23:in `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace) (Executor::NonZeroExitStatus)

我在这里发现了一个类似的问题:issue deploying rails 5 application to AWS using Elastic Beanstalk due to rb-readline

昨天我还问了另一个关于psych错误的问题(下面贴出了链接),但我开始认为这个错误可能是由于对HOME 的引用无效造成的>。在这一点上我很迷茫,并且已经为此工作了几个小时,但绝对没有运气。

我昨天发布的另一个关于心理错误的问题: Error Deploying on Elastic Beanstalk - Rails

最佳答案

ruby :2.7.0 rails :6.0.2.1 固相线:v2.10.0

只需将下面的“命令”部分添加到您的 .ebextensions/packages.config

添加所需的命令:

# Setup linux packages
option_settings:
  - option_name: BUNDLE_DISABLE_SHARED_GEMS
    value: "1"
  - option_name: BUNDLE_PATH
    value: "vendor/bundle"

packages:
  yum:
    git: []
    ImageMagick: []
    ImageMagick-devel: []
    openssl-devel: []
    postgresql93-devel: []

commands:
  01_node_get:
    # run this command from /tmp directory
    cwd: /tmp
    # flag -y for no-interaction installation
    command: 'curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -'

  02_node_install:
    # run this command from /tmp directory
    cwd: /tmp
    command: 'sudo yum -y install nodejs'

  03_yarn_get:
    # run this command from /tmp directory
    cwd: /tmp
    # don't run the command if yarn is already installed (file /usr/bin/yarn exists)
    test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
    command: 'sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo'

  04_yarn_install:
    # run this command from /tmp directory
    cwd: /tmp
    test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
    command: 'sudo yum -y install yarn'

  05_home_dir:
    test: '[ ! -p /home/webapp ] && echo "webapp not exited"'
    command: 'sudo mkdir -p /home/webapp'

  06_grant_home_dir:
    test: '[ ! -p /home/webapp ] && echo "webapp not exited"'
    command: 'sudo chmod 777 /home/webapp'

来源: https://medium.com/@tranduchanh.ms/deploy-and-manage-production-rails-5-app-with-aws-elastic-beanstalk-3efb0dfe021a

关于ruby-on-rails - `/home/webapp` 不是目录 - Elastic Beanstalk (RAILS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53948607/

相关文章:

ruby-on-rails - Ember 模型只加载最后一条记录

javascript - 在所有数据加载之前检测时区

ruby-on-rails - rspec - 找不到命令

ruby - ActiveRecord 模型的互斥锁

ruby - 检查散列是否有一个包含一些文本的键

Python Boto3 : Error when trying to download files from AWS S3

amazon-web-services - AWS 中使用 cloudformation 创建的手动更新堆栈将来会导致冲突吗?

ruby-on-rails - 删除角色 PostgreSQL 失败 - 数据库缓存查找失败

ruby-on-rails - Rails 4 强制将默认路由参数包含在生成的 URL 中

javascript - 如何从 aws lambda 调用获取完整日志?