运行代码部署挂钩时找不到Go命令

问题描述 投票:0回答:1

您好我正在尝试为我的golang应用程序创建CodeDeploy部署。我有一个自动缩放组,它使用我创建的AMI,它包含我需要安装的所有库。当我尝试运行CodeDeploy时,它存在于我的after_install中的错误:

LifecycleEvent - AfterInstall
Script - scripts/after_install.sh
[stderr]/opt/codedeploy-agent/deployment-root/a65d9a2e-fddd-471c-8ea1-c018792d00bd/d-4IKP3PP4Y/deployment-archive/scripts/after_install.sh: 
line 4: go: command not found

我知道go已安装在服务器上,我可以通过sshing到服务器并运行go命令来验证。最初我把我的after_install钩子作为root运行,这就是为什么我认为它抱怨没有安装。

我更新它以运行ubuntu这里是appspec文件

version: 0.0
os: linux
files:
  - source: ./
    destination: ./home/ubuntu/code
hooks:
  AfterInstall:
    - location: scripts/after_install.sh
      timeout: 180
      runas: ubuntu
  ApplicationStart:
    - location: scripts/application_start.sh
      timeout: 180
      runas: root

但我仍然得到找不到go命令的错误。我作为ubuntu用户SSH进入服务器,我可以清楚地看到go已安装。

我更进了一步并运行了after_install.sh文件,它没有任何错误。我在这做错了什么?

只是为了额外好奇这里是我的after_install.sh文件

#!/bin/bash

cd /home/ubuntu/code/vibeify/cmd/vibeify
go build
amazon-web-services go aws-code-deploy
1个回答
0
投票

如果只能在交互式shell中使用没有完整安装路径的go命令,请检查$HOME/.bashrc

它可能取决于操作系统默认设置,但某些操作系统默认的bashrc文件包含不在非交互式shell中加载配置文件的脚本。

# open $HOME/.bashrc file
# and comment out these lines
case $- in
    *i*) ;;
      *) return;;
esac
© www.soinside.com 2019 - 2024. All rights reserved.