Skip to content

apollo-cli-install fails with missing “sh” file error #3591

@3redrubies

Description

@3redrubies

Summary

When running the Swift package plugin to install the Apollo CLI from a package directory, the process fails due to what seems like an issue with resolving the shell executable path.

We might be missing something here — would love to know if anyone else has run into this or if we’re doing something wrong.

Version

2.0.0

Steps to reproduce the behavior

Run the following command in a package directory with Package.swift and Apollo 2.0.0 as a dependency:

swift package plugin --allow-writing-to-package-directory --allow-network-connections all apollo-cli-install

The command fails with the following error:
Error Domain=NSCocoaErrorDomain Code=4 "The file “sh” doesn’t exist." UserInfo={NSFilePath=/Users/.../file:/bin/sh}

Attached a minimum reproducible example.

ApolloBugTest.zip

Logs

Anything else?

Investigation:

We updated process arguments in InstallCLIPluginCommand.swift as follows:

process.arguments = [
  dep.package.directoryURL.appending(path: "scripts/download-cli.sh").path,
  context.package.directoryURL.absoluteString
]

After this change, the plugin now fails with:
/bin/sh: file:///Users/.../.build/checkouts/apollo-ios/scripts/download-cli.sh: No such file or directory

We also needed to modify the download-cli.sh script to correctly handle the project directory path.

APOLLO_VERSION=$(sh "$directory/get-version.sh")
DOWNLOAD_URL="https://www.github.com/apollographql/apollo-ios/releases/download/$APOLLO_VERSION/apollo-ios-cli.tar.gz"
if [[ "$projectDir" == file://* ]]; then
  projectDir="${projectDir#file://}"
fi
FILE_PATH="${projectDir}apollo-ios-cli.tar.gz"
curl -L "$DOWNLOAD_URL" -s -o "$FILE_PATH"
tar -xvf "$FILE_PATH"
rm -f "$FILE_PATH"

After applying the above change, the script executes successfully and completes the CLI installation.

Metadata

Metadata

Assignees

Labels

bugGenerally incorrect behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions