【问题标题】:how to specify a ruby version in my appspec file for aws codedeploy如何在我的 appspec 文件中为 aws codedeploy 指定 ruby​​ 版本
【发布时间】:2018-02-04 01:34:29
【问题描述】:

我正在尝试将 ruby​​ 应用程序部署到 codedeploy 并且当它安装 Sinatra 时,它一直给我一个错误,它需要更高版本的 ruby​​ 然后安装在服务器上。如何指定要使用的版本?

我在我的 Gemfile 中指定了它,在 appspecfile 中尝试了几种方法

LifecycleEvent - BeforeInstall
Script - scripts/install_dependencies
[stdout]Successfully installed bundler-1.15.4
[stdout]Parsing documentation for bundler-1.15.4
[stdout]Done installing documentation for bundler after 5 seconds
[stdout]1 gem installed
[stdout]Updating installed gems
[stdout]Nothing to update
[stderr]ERROR:  Error installing sinatra:
[stderr]    rack requires Ruby version >= 2.2.2. 

我已经在我的 appspec.yml 文件中尝试过这个

language: ruby
rvm:
  - 2.4.1
  - jruby-head
Before_install:  # For jruby-head to work.
  - gem install bundler
  - gem update bundler

任何形式的帮助都会很棒,谢谢

这是我在尝试上面找到的之前的 appspec.yml 版本

version: 0.0
os: linux
files:
  - source: /.
   destination: /var/www/html/
hooks:
  BeforeInstall:
    - location: scripts/install_dependencies
      timeout: 300
      runas: root
    - location: app.rb
      timeout: 300
      runas: root
  ApplicationStop:
    - location: app.rb
      timeout: 300
      runas: root
  ApplicationStart:
    - location: app.rb
      timeout: 300
      runas: root

宝石文件

source 'https://rubygems.org'
ruby "~> 2.3.0"
gem 'sinatra', '2.0.0'

【问题讨论】:

    标签: ruby amazon-web-services yaml aws-code-deploy


    【解决方案1】:

    CodeDeploy appspec 实际上不需要支持该选项,每个生命周期事件的脚本都将使用 env ruby​​ 运行。如果您想运行特定版本的 ruby​​,可能您可以在其中一个脚本中将其更改为默认 ruby​​ 版本,用于生命周期事件之一,例如 BeforeInstall。

    【讨论】:

      猜你喜欢
      • 2018-02-26
      • 2019-01-03
      • 1970-01-01
      • 2023-03-16
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 2016-05-28
      • 2020-02-03
      相关资源
      最近更新 更多