dsafq2131321 2019-04-25 22:36
浏览 248

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

Hello I'm trying to create a CodeDeploy deployment for my golang application. I have an autoscaling group that uses a AMI I created that has all the libs I need installed. When I try to run CodeDeploy it exists with an error in my 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

I know go is installed on the server I can verify by sshing into the server and running the go command. Initially I had my after_install hook run as root so that's why I thought it complained about go not being installed.

I updated it to run as ubuntu here is the appspec file

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

But I still get the error of go command not found. I SSH into the server as ubuntu user and I can clearly see go is installed.

I took it one step further and ran the after_install.sh file and it worked with no errors. What am I doing wrong here?

Just for the extra curious here is my after_install.sh file

#!/bin/bash

cd /home/ubuntu/code/vibeify/cmd/vibeify
go build
  • 写回答

1条回答 默认 最新

  • doupin2013 2019-04-25 23:50
    关注

    If you can use go command without the full installation path only in the interactive shell, check $HOME/.bashrc.

    It may depends on OS default settings, but some OS default bashrc file includes scripts that does not load profile in non-interactive shell.

    # open $HOME/.bashrc file
    # and comment out these lines
    case $- in
        *i*) ;;
          *) return;;
    esac
    
    评论

报告相同问题?

悬赏问题

  • ¥15 速帮,学校需要在外上班没空
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义