eas-cli icon indicating copy to clipboard operation
eas-cli copied to clipboard

app.config.js output to stdout breaks Gradle build

Open nmschulte-aviture opened this issue 2 years ago • 7 comments

Build/Submit details page URL

No response

Summary

The console.log diagnostic executed from app.config.js causes eas build --profile android to fail running gradlew's :app:bundleReleaseJsAndAssets.

ex: console.log(`APP_VARIANT is "${JSON.stringify(process.env.APP_VARIANT)}"`)

> Task :app:bundleReleaseJsAndAssets
APP_VARIANT is "development"
warning: the transform cache was reset.
Error: The resource `/home/expo/workingdir/build/APP_VARIANT is "development"
index.js` was not found.
    at /home/expo/workingdir/build/node_modules/metro/src/IncrementalBundler.js:297:24
    at gotStat (fs.js:1782:21)
    at FSReqCallback.oncomplete (fs.js:168:21)
info Run CLI with --verbose flag for more details.
> Task :app:bundleReleaseJsAndAssets FAILED

Using console.error (stderr) instead mitigates the issue.

Managed or bare?

managed

Environment

N/A

Error output

No response

Reproducible demo or steps to reproduce from a blank project

(see description)

nmschulte-aviture avatar Jul 21 '22 22:07 nmschulte-aviture

I cannot reproduce the issue using provided steps.

dsokal avatar Aug 12 '22 11:08 dsokal

Hi there! It looks like your issue requires a minimal reproducible example, but it is invalid or absent. Please prepare such an example and share it in a new issue.

The best way to get attention to your issue is to provide a clean and easy way for a developer to reproduce the issue on their own machine. Please do not provide your entire project, or a project with more code than is necessary to reproduce the issue.

A side benefit of going through the process of narrowing down the minimal amount of code needed to reproduce the issue is that you may get lucky and discover that the bug is due to a mistake in your application code that you can quickly fix on your own.

Resources

Common concerns

"I've only been able to reproduce it in private, proprietary code"

You may not have spent enough time narrowing down the root cause of the issue. Try out the techniques discussed in this manual debugging guide to learn how to isolate the problem from the rest of your codebase.

"I didn't have time to create one"

That's understandable, it can take some time to prepare. We ask that you hold off on filing an issue until you are able to fully complete the required fields in the issue template.

"You can reproduce it by yourself by creating a project and following these steps"

This is useful knowledge, but it's still valuable to have the resulting project that is produced from running the steps, where you have verified you can reproduce the issue.

expo-bot avatar Aug 12 '22 11:08 expo-bot

I just had this same problem. Commenting out console.log lines from app.config.js - as unbelievable as it sounds - fixed the issue.

danielricecodes avatar Aug 15 '22 22:08 danielricecodes

Same issue here, removing the console log fixes it

eprice122 avatar Aug 20 '22 21:08 eprice122

Noting here my EAS builds on Expo in SDK 45 were failing and it was too to do with having a console.log in the app.config.js

AlastairTaft avatar Aug 24 '22 03:08 AlastairTaft

Can any of you share a reproducible example of the issue?

dsokal avatar Aug 24 '22 07:08 dsokal

npx expo init my-app --template blank
cd my-app/
eas init
eas build:configure --platform=android
cat <<- EOF > app.config.js
export default ({ config }) => {
  console.log('break\nbreak');
  config.android.package = 'my.app';
  return config;
};
EOF

npx eas build --platform=android : --

Error: The resource `/home/expo/workingdir/build/break

break

index.js` was not found.

    at /home/expo/workingdir/build/node_modules/metro/src/IncrementalBundler.js:297:24

    at gotStat (node:fs:2637:21)

    at FSReqCallback.oncomplete (node:fs:198:21)

nmschulte-aviture avatar Aug 24 '22 15:08 nmschulte-aviture

I just had this same problem. Commenting out console.log lines from app.config.js - as unbelievable as it sounds - fixed the issue.

Well... That doesn't sound THAT unveliabeble. Usually config files paths are used in terminal-commands (like... mycommand install --config=./blabla/config.json), so, any output in that file may be shown in the terminal, producing a "non zero" output in the command, which may broke commands ran on chain, as in: npm i && npm run build.

Consider it for the future. People that had worked with PHP had learned this in the harder way, lot of years ago hehehe. #WeLoveDrupal

BrodaNoel avatar Nov 07 '22 21:11 BrodaNoel