【问题标题】:Execute Fastlane Command missing Gem when operating cron job运行 cron 作业时执行 Fastlane 命令缺少 Gem
【发布时间】:2021-11-03 04:14:46
【问题描述】:

当我转到 Mac 终端并使用包含以下命令集执行我的 sh 文件时,它运行顺利。当我允许我的裁剪选项卡在上午 9 点到晚上 18 点之间每隔一小时执行时,它会显示以下例外情况

Fetching origin
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Already up to date.
Already on 'feature/sprint_1'
M   src/Podfile.lock
M   src/MyProject/Info.plist
Your branch is up to date with 'origin/feature/sprint_7'.
bundler: command not found: fastlane
Install missing gem executables with `bundle install`

在我的项目文件夹结构中,存在GemfileGemfile.lock。我需要..

  1. 在执行我的命令集之前修改 Gemfile?
  2. 以超级用户 sudo 访问权限执行我的命令?
  3. 如果正确安装了 bundle 和 fastlane,我如何确认要执行的文件路径是正确的?

4.以下是我的 .sh 文件,其中包含以下命令集:我是否还需要修改我的命令集?

cd ~/myProject/src && git stash clear && git fetch --all && git pull && git checkout $1 && bundle exec fastlane ios build build_type:adhoc build_env:dev

$1 是我提议的分支,例如master, release , feature/sprint_1

【问题讨论】:

  • 从 git 开始,您会收到一个警告(简而言之 - 您可能有不可预知的合并,这意味着可能会发生不希望的更改),您可以在此处处理它 (*.com/a/62653400/6901693)。然后你找不到命令“fastlane” - 请参阅此处如何修复它*.com/a/46216913/6901693。并查看最后一个“安装缺失的 gem” - 尝试安装所有软件包并重新启动终端(更多信息可以在这里找到*.com/a/6010234/6901693)。请让我知道这是否足以让您继续或修复它。

标签: macos cron bundle fastlane


【解决方案1】:

根据您日志的最后 3 行:

Your branch is up to date with 'origin/feature/sprint_7'.
bundler: command not found: fastlane
Install missing gem executables with `bundle install`

你的脚本开头有 cd 和 4 个 git 命令。我会假设 $1 是主人。基本上是这样的:

cd ~/myProject/src 
git stash clear
git fetch --all
git pull 
git checkout master # or $1
bundle exec fastlane ios build build_type:adhoc build_env:dev

Bundler 显示command not found: fastlane,然后显示解决方案,即您需要运行bundle install

当您在bundle exec 之前添加捆绑安装时,您可能会解决您的问题:

cd ~/myProject/src 
git stash clear
git fetch --all
git pull 
git checkout master # or $1
bundle install
bundle exec fastlane ios build build_type:adhoc build_env:dev

【讨论】: