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

Command PhaseScriptExecution failed with a nonzero exit code (0.13.0) #667

Closed
davanyushkin opened this issue Jul 24, 2019 · 21 comments
Closed
Labels
build-issue Issues occurring when attempting to build

Comments

@davanyushkin
Copy link

davanyushkin commented Jul 24, 2019

I update apollo-iOS to a new version (0.13.0)
When I trying to make codegen for schema.json file I get error while running shell-script
i recieve message like this one:
++ npx --no-install apollo codegen:generate --target=swift '--includes=./**/*.graphql' --localSchemaFile=schema.json API.swift Loading Apollo Project [started] Loading Apollo Project [completed] Generating query files [started] Generating query files with 'swift' target [title changed] Generating query files with 'swift' target [failed] → No operations or fragments found to generate code for. (node:1521) UnhandledPromiseRejectionWarning: Error: No operations or fragments found to generate code for. at write (/Users/dmitrijvanuskin/Desktop/BorrowLend/BorrowLand/Application/BorrowLend/node_modules/apollo/lib/commands/client/codegen.js:61:39) at GraphQLClientProject._onDiagnostics (/Users/dmitrijvanuskin/Desktop/BorrowLend/BorrowLand/Application/BorrowLend/node_modules/apollo/lib/commands/client/codegen.js:84:29) at GraphQLClientProject.validate (/Users/dmitrijvanuskin/Desktop/BorrowLend/BorrowLand/Application/BorrowLend/node_modules/apollo-language-server/lib/project/client.js:140:18) at GraphQLClientProject.validateIfNeeded (/Users/dmitrijvanuskin/Desktop/BorrowLend/BorrowLand/Application/BorrowLend/node_modules/apollo-language-server/lib/project/base.js:136:14) at Timeout._onTimeout (/Users/dmitrijvanuskin/Desktop/BorrowLend/BorrowLand/Application/BorrowLend/node_modules/apollo-language-server/lib/project/base.js:128:22) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7) (node:1521) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3) (node:1521) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Error: No operations or fragments found to generate code for. at write (~/Desktop/BorrowLend/BorrowLand/Application/BorrowLend/node_modules/apollo/lib/commands/client/codegen.js:61:39) at Task.task (~/Desktop/BorrowLend/BorrowLand/Application/BorrowLend/node_modules/apollo/lib/commands/client/codegen.js:86:46) Command PhaseScriptExecution failed with a nonzero exit code

I am currently using apollo 2.16.1 and XCode 10.3. All steps are similar to apollo ios guide

@designatednerd
Copy link
Contributor

Hey Dmitry, have you added any .grapqhl query files to your project yet? It looks like it won't generate any code because it can't find the files.

@davanyushkin
Copy link
Author

Yes, I have already added them to my project. I use apollo-ios for 3 months and it generated API.swift successfully in the previous version but after update of schema.json and apollo-ios version I get some problems.
Снимок экрана 2019-07-24 в 17 34 34

@designatednerd
Copy link
Contributor

It looks like it's not finding them - that's the → No operations or fragments found to generate code for error. it looks like you're using the proper glob to search recursively for them, so that's not the issue. Can you validate that when you add echo $(pwd) right after the next-to-last line of the script that schema.json is in that same directory? Otherwise you'd need to pass the relative path to schema.json.

@davanyushkin
Copy link
Author

Thanks, when I add echo $(pwd) i get out of build errors, but no API.swift file generated now

@designatednerd
Copy link
Contributor

designatednerd commented Jul 24, 2019

That's...weird. echo $(pwd) should just print out the working directory, but it shouldn't cause the errors to stop (unless maybe you replaced the line that actually runs the script with it?). Are you at least getting the correct working directory? ex, if you change it to echo "Working dir = $(pwd)" does what gets printed there seem correct?

@designatednerd designatednerd added the build-issue Issues occurring when attempting to build label Jul 24, 2019
@davanyushkin
Copy link
Author

davanyushkin commented Jul 24, 2019

Yes, it prints correct directory, where schema.json and .graphql file and .swift files are placed
But about error is really weird - I add this line as last without replacing another. Really weird...

@joninsky
Copy link

I'm having the same issue. I used the echo $(pwd) command and I am in the same directory as my schema.json file. I also re-introspected the schema.json file from my server.

I also upgraded to Xcode 10.3 this morning. There was a separate Xcode 10.3 issue I had to fix related to simulators not showing up. Finally, .graphql syntax highlighting stopped working in Xcode 10.3 eventhough the appropriate files are still present in the plug-ins directory. I know it's a separate issue but you never know what is related!

@designatednerd
Copy link
Contributor

@DmitryVanyshkin And if you comment out the echo line does it go back to giving you the same errors you were getting before? What happens if you do the Derived Data Dance (quit Xcode, delete ~/Library/Developer/Xcode/DerivedData, start Xcode again, rebuild)?

@designatednerd
Copy link
Contributor

@joninsky The 10.3 syntax highlighting issue is related to UUIDs in the plugin - hopefully I can get that merged and updated shortly. Can you link to which of Dmitry's messages contains the error you're getting?

@joninsky
Copy link

I deleted the node_modules folder in my project and it will successfully do the code generation now.

However, I am at a new issue where all my queries that I am passing into the ApolloClient's are compile time flagged as Controller.swift:47:28: Generic parameter 'Query' could not be inferred

It looks like some people on the other thread are having the same issue.

@designatednerd
Copy link
Contributor

@joninsky and anyone else running into that issue: Please see the 0.13.0 release notes - that's got info on how to fix that (spoiler: it's about the change from a tuple to a Result)

@davanyushkin
Copy link
Author

Yes, if I comment echo line the same error goes back. About DerivedData - there is no such folder, but I use clean Build (cmd+shift+K) and it doesn't resolve my problem.

@joninsky
Copy link

Thank you @designatednerd ! So happy to have someone working full time on this library. 🙏🏽🙏🏽🙏🏽 I'm thrilled we have release notes with breaking changes now!

@designatednerd
Copy link
Contributor

@DmitryVanyshkin Yeah theoretically that and deleting Derived Data do the same thing, in practice I've found sometimes I still need to nuke it from orbit, just to be sure.

Can you send me your project via email? ellen at apollographql dot com. I'll try to take a look in the morning.

@designatednerd
Copy link
Contributor

OK the look was quicker than I thought - seems like there was a syntax error in the .graphql file (similar to #664), and fixing that brought up a whole mess of other issues.

Anyone else reading: If you're having problems with this, I've been able to identify bad syntax really easily using this formatter - it can't tell you if you're using the wrong queries or properties or anything, but it can tell you if your GQL has a syntax error, and will tell you exactly where.

@davanyushkin
Copy link
Author

Thank you a lot! That was rather stupid mistake from me. You are my hero!!

@moax
Copy link

moax commented Jul 30, 2019

Im trying to build the API.swift file for days now and I continue to run into the same error (nonzero exit code). It sopped showing the error code after adding echo $(pwd).

++ npx --no-install apollo codegen:generate --target=swift --localSchemaFile=schema.json API.swift
⚠️  It looks like there are 0 files associated with this Apollo Project. This may be because you don't have any files yet, or your includes/excludes fields are configured incorrectly, and Apollo can't find your files. For help configuring Apollo projects, see this guide: https://bit.ly/2ByILPj
Loading Apollo Project [started]
Loading Apollo Project [completed]
Generating query files [started]
Generating query files with 'swift' target [title changed]
Generating query files with 'swift' target [failed]
→ No operations or fragments found to generate code for.
Error: No operations or fragments found to generate code for.
   at write (~/node_modules/apollo/lib/commands/client/codegen.js:61:39)
   at Task.task (~/node_modules/apollo/lib/commands/client/codegen.js:86:46)
/Users/../Documents/XCode_Projects/LISA_Monitoring/LISA Monitoring

I only use the schema.json file within the project folder and the codegen script is opening the file. I checked this by adding characters to the json file leading to an exact error message.

I checked the scheme for correct formatting and uploaded the valid but optimized version to my server and extracted the scheme as json via the apollo command. The error still occurs.

At least Xcode is building the app now after I added the echo $(pwd) command.

I uploaded the schema.json here.
schema.txt

@designatednerd
Copy link
Contributor

It looks like the script isn't finding the query files from this error: → No operations or fragments found to generate code for.

Can you take a look at what you're passing in for --includes? It doesn't seem to be present in the output above. Without that, the script has no idea where to look for .graphql files and it won't work.

@moax
Copy link

moax commented Jul 30, 2019

This is the code from build phase:
cd "${SRCROOT}/${TARGET_NAME}" "${APOLLO_FRAMEWORK_PATH}"/check-and-run-apollo-cli.sh codegen:generate --target=swift --localSchemaFile=schema.json --includes=./*.graphql API.swift echo $(pwd)
I left "--includes=.." out as it was giving me duplication errors, but I guess I am wrong with that. After adding "--includes=.." again it throws this errors:

++ npx --no-install apollo codegen:generate --target=swift --localSchemaFile=schema.json '--includes=./*.graphql' API.swift Loading Apollo Project [started] CLIError: Error in "Loading schema for Unnamed Project": Error: Type "Query" already exists in the schema. It cannot also be defined in this type definition. Field "Query.aircrafts" already exists in the schema. It cannot also be defined in this type extension. Field "Query.aircraft" already exists in the schema. It cannot also be defined in this type extension. Field "Query.sensors" already exists in the schema. It cannot also be defined in this type extension. Field "Query.sensor" already exists in the schema. It cannot also be defined in this type extension. Field "Query.sensorvalues" already exists in the schema. It cannot also be defined in this type extension. at Object.error (/usr/local/lib/node_modules/apollo/node_modules/@oclif/errors/lib/index.js:22:17) at Generate.error (/usr/local/lib/node_modules/apollo/node_modules/@oclif/command/lib/command.js:57:23) at OclifLoadingHandler.showError (/usr/local/lib/node_modules/apollo/lib/OclifLoadingHandler.js:28:22) at OclifLoadingHandler.handle (/usr/local/lib/node_modules/apollo/lib/OclifLoadingHandler.js:13:18) { oclif: { exit: 2 }, code: undefined } Loading Apollo Project [failed] → Error initializing Apollo GraphQL project "Unnamed Project": Error: Error in "Loading schema for Unnamed Project": Error: Type "Query" already exists in the schema. It cannot also be defined in this type definition. Field "Query.aircrafts" already exists in the schema. It cannot also be defined in this type extension. Field "Query.aircraft" already exists in the schema. It cannot also be defined in this type extension. Field "Query.sensors" already exists in the schema. It cannot also be defined in this type extension. Field "Query.sensor" already exists in the schema. It cannot also be defined in this type extension. Field "Query.sensorvalues" already exists in the schema. It cannot also be defined in this type extension. › Error: Error initializing Apollo GraphQL project "Unnamed Project": Error: › Error in "Loading schema for Unnamed Project": Error: Type "Query" already › exists in the schema. It cannot also be defined in this type definition. › › Field "Query.aircrafts" already exists in the schema. It cannot also be › defined in this type extension. › › Field "Query.aircraft" already exists in the schema. It cannot also be › defined in this type extension. › › Field "Query.sensors" already exists in the schema. It cannot also be › defined in this type extension. › › Field "Query.sensor" already exists in the schema. It cannot also be › defined in this type extension. › › Field "Query.sensorvalues" already exists in the schema. It cannot also be › defined in this type extension. /Users/../Documents/XCode_Projects/LISA_Monitoring/LISA Monitoring

I have only the query.graphql file in my project:
type Query { aircrafts: [Aircraft] aircraft(id: ID!): Aircraft sensors(pageSize: Int, after: String): Sensors! sensor(id: ID!): Sensor sensorvalues(sensorID: ID, pageSize: Int, after: String): Values! }

@designatednerd
Copy link
Contributor

The query is not formatted correctly, which is why you're getting those errors. You'd need something more like:

query AircraftList {
  aircrafts {
    ... on Aircraft {
      id
    }
  }
}

To get a list of aircraft that returns every aircraft's ID from the schema you sent. Try messing around with GraphiQL or a similar tool on your site, that should help you come up with valid queries.

@lipizr
Copy link

lipizr commented Dec 21, 2019

My fix was to remove a hard version target in my Podfile. Once I changed to pod 'Apollo' and ran pod install again it works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-issue Issues occurring when attempting to build
Projects
None yet
Development

No branches or pull requests

5 participants