【问题标题】:Yarn executable was not detected in the system while deploying rails 6 to AWS Beanstalk将 rails 6 部署到 AWS Beanstalk 时,系统中未检测到 Yarn 可执行文件
【发布时间】:2020-11-16 01:22:49
【问题描述】:

尝试在 AWS Beanstalk 上部署 Ruby on Rails 应用程序。 Ruby 版本是 2.6.6,Rails 版本是 5.2.3。 RDS 和其他设置已完成,但是当我不使用 eb deploy 时,它会在资产预编译时出错。错误是未检测到纱线。在这个应用程序中,我也有 webpack gem,因为需要这种纱线

+ 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/bundler20200726-3166-q5qdvj3166' 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/bundler20200726-3256-1yqrnzx3256' as your home directory temporarily.
  Yarn executable was not detected in the system.
  Download Yarn at https://yarnpkg.com/en/docs/install
  rake aborted!
  SassC::SyntaxError: Error: File to import not found or unreadable: bootstrap/scss/bootstrap.
          on line 16:1 of app/assets/stylesheets/application.scss
  >> @import "bootstrap/scss/bootstrap";
  
     ^
  /var/app/ondeck/app/assets/stylesheets/application.scss:16
  Tasks: TOP => assets:precompile
  (See full trace by running task with --trace) (Executor::NonZeroExitStatus)


[2020-07-26T15:41:34.604Z] ERROR [2838]  : Command CMD-AppDeploy failed!
[2020-07-26T15:41:34.604Z] INFO  [2838]  : Command processor returning results: 
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"(TRUNCATED)...ootstrap.\n        on line 16:1 of app/assets/stylesheets/application.scss\n>> @import \"bootstrap/scss/bootstrap\";\n\n   ^\n/var/app/ondeck/app/assets/stylesheets/application.scss:16\nTasks: TOP => assets:precompile\n(See full trace by running task with --trace). \nHook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":1,"events":[]}],"truncated":"true"}

虽然我在 .ebextensions 中创建了一个配置文件 yarn.config

 01_node_get:
cwd: /tmp
command: 'sudo curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash -'

02_node_install:
cwd: /tmp
command: 'sudo yum -y install nodejs'

03_yarn_get:
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:
cwd: /tmp
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo yum -y install yarn'

我该如何解决这个问题?

【问题讨论】:

    标签: ruby-on-rails amazon-web-services webpack amazon-elastic-beanstalk yarnpkg


    【解决方案1】:

    问题在于@import "bootstrap/scss/bootstrap" 的路径;

    应该是

    "node_modules/bootstrap/scss/bootstrap";

    路径应该是相对于根的

    【讨论】:

    • @import "bootstrap/scss/bootstrap";
    • @import "bootstrap/scss/bootstrap";基本上这些都在 node_modules 里面
    • 好的,那么@import 应该是 ""node_modules/bootstrap/scss/bootstrap"
    • 但在 Rails 中我们不推送 node_module ...它将使用 assets:precompile 构建
    猜你喜欢
    • 1970-01-01
    • 2018-01-11
    • 2020-11-13
    • 2013-04-03
    • 2015-04-05
    • 1970-01-01
    • 2020-03-24
    • 2016-07-08
    • 2018-09-23
    相关资源
    最近更新 更多