Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH connection to GitHub fails at Install dependencies #2335

Open
tsuyuni opened this issue Apr 20, 2024 · 3 comments
Open

SSH connection to GitHub fails at Install dependencies #2335

tsuyuni opened this issue Apr 20, 2024 · 3 comments
Labels
eas build needs review Issue is ready to be reviewed by a maintainer

Comments

@tsuyuni
Copy link

tsuyuni commented Apr 20, 2024

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

"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

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.

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/{organization-name}/{repository-name}.git
npm ERR! [email protected]: 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 [email protected] 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://[email protected]/{organization-name}/{repository-name}.git
npm ERR! Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
npm ERR! [email protected]: 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

@tsuyuni tsuyuni added the needs review Issue is ready to be reviewed by a maintainer label Apr 20, 2024
@szdziedzic
Copy link
Member

Interesting, I've never encountered something like this before 🤔

We are not touching anything ssh related in our system between the PRE_INSTALL_HOOK and INSTALL_DEPENDENCIES phases 🤔

This is our source code:
https://github.com/expo/eas-build/blob/ad8252736c2b8e7a585efc934163c9a208477820/packages/build-tools/src/common/setup.ts#L47-L60
https://github.com/expo/eas-build/blob/ad8252736c2b8e7a585efc934163c9a208477820/packages/build-tools/src/common/installDependencies.ts#L10-L32

@mafikes
Copy link

mafikes commented Jun 20, 2024

The same issue. yarn install or npm ci not help me in the pre-install.

I tried submodules and this from documentation not work too. https://docs.expo.dev/build-reference/git-submodules/

@gaiao
Copy link

gaiao commented Nov 3, 2024

Same issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
eas build needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants