SSH connection to GitHub fails at Install dependencies
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 236
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 91
Description
### Build/Submit details page URL
https://expo.dev/accounts/mairu-tech/projects/mairu-crew/builds/5310dcc3-fbc1-42ec-a3e1-679658897390
### Summary
I encountered an issue while attempting to use my own npm package from a private GitHub repository in my project. To achieve this, I configured pre-install scripts to access the repository using an SSH key. The private key is encoded in Base64 and stored in the $DEPLOY_KEY variable.
./package.json
```json
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"postinstall": "patch-package",
"eas-build-pre-install": "./pre-install"
},
```
./pre-install
```sh
eval "$(ssh-agent -s)"
echo "$DEPLOY_KEY" | base64 -d > ~/.ssh/eas_id
chmod 0600 ~/.ssh/eas_id
ssh-add ~/.ssh/eas_id
touch ~/.ssh/config
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
```
However, this pre-install scripts result in this error at Install Independency phase.
```sh
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/{organization-name}/{repository-name}.git
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
```
To solve this problem, I added `npm ci` at the last line of pre-install scripts. And this worked for me. But I wonder why I can't access to private repository at Install Independency phase. Does the configurations set at pre-install phase disappear at Install Independency phase?
### Managed or bare?
Managed
### Environment
expo-env-info 1.2.0 environment info:
System:
OS: macOS 14.2
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.6.2 - /opt/homebrew/bin/node
Yarn: 1.22.21 - /opt/homebrew/bin/yarn
npm: 10.2.4 - /opt/homebrew/bin/npm
Watchman: 2024.01.22.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.12.1 - /Users/meiyu/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.4, iOS 17.4, macOS 14.4, tvOS 17.4, visionOS 1.1, watchOS 10.4
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11330709
Xcode: 15.3/15E204a - /usr/bin/xcodebuild
npmPackages:
@expo/webpack-config: ^19.0.1 => 19.0.1
expo: ~50.0.13 => 50.0.14
expo-router: ~3.4.8 => 3.4.8
react: 18.2.0 => 18.2.0
react-native: ^0.73.6 => 0.73.6
react-native-web: ~0.19.6 => 0.19.10
npmGlobalPackages:
eas-cli: 7.6.0
expo-cli: 6.3.10
Expo Workflow: managed
✔ Check Expo config for common issues
✔ Check package.json for common issues
✔ Check dependencies for packages that should not be installed directly
✔ Check for issues with metro config
✔ Check for common project setup issues
✔ Check npm/ yarn versions
✔ Check Expo config (app.json/ app.config.js) schema
✖ Check that packages match versions required by installed Expo SDK
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✔ Check that native modules use compatible support package versions for installed Expo SDK
✔ Check native tooling versions
I just need react-native-get-random-values@1.9.0 to use @aws-amplify/react-native, though expected version by Expo SDK is ~1.8.0.
### Error output
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/{organization-name}/{repository-name}.git
npm ERR! Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
### Reproducible demo or steps to reproduce from a blank project
Described at Summary section
Contributor guide
Assessment
This issue has not been assessed yet.