Google compute engine 在Google云平台上创建实例时无法运行启动脚本

Google compute engine 在Google云平台上创建实例时无法运行启动脚本,google-compute-engine,Google Compute Engine,我有一个简单的启动脚本,如下所示: #!/usr/bin/env bash sudo apt update sudo apt install -y ruby-full ruby-bundler build-essential $ chmod +x startup.sh 并在GCP上创建VM实例,如下所示: $ gcloud compute instances create test-app --boot-disk-size=10GB --image-family ubuntu-1604-lt

我有一个简单的启动脚本,如下所示:

#!/usr/bin/env bash
sudo apt update
sudo apt install -y ruby-full ruby-bundler build-essential
$ chmod +x startup.sh
并在GCP上创建VM实例,如下所示:

$ gcloud compute instances create test-app --boot-disk-size=10GB --image-family ubuntu-1604-lts --image-project=ubuntu-os-cloud --machine-type=g1-small --zone europe-west1-b --tags test-server --restart-on-failure --metadata-from-file startup-script=startup.sh
我的
startup.sh
是可执行的。我这样设定它的权利:

#!/usr/bin/env bash
sudo apt update
sudo apt install -y ruby-full ruby-bundler build-essential
$ chmod +x startup.sh
然而,当我进入新创建的实例的外壳并检查bundler时:

test-app:~$ bundle -v
我收到这些信息:

程序“bundle”当前未安装


那么,这有什么问题,我该如何解决?另外,如果我只是从实例外壳内部运行所有命令,那么一切都正常,因此在GCP上使用启动脚本会出现一些问题。

我使用您的用例进行了测试,但是安装了捆绑包,没有做任何更改

输出:
bundle-v
捆绑机版本1.11.2

您可以检查VM串行控制台日志输出,以验证启动脚本是否已运行。检查VM实例以验证是否使用以下命令安装了包:

sudo apt list --installed | grep -i bundle
sudo egrep bundle /var/log/dpkg.log
此外,请检查
gem列表捆绑包