Apollo-ios: The version of Apollo.framework in your project requires Apollo CLI 1.2.0, but apollo/1.6.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...

Created on 31 Jul 2018  ·  38Comments  ·  Source: apollographql/apollo-ios

It looks like REQUIRED_APOLLO_CLI_VERSION=1.2.0 in check-and-run-apollo-cli.sh prevents us from using latest version of Apollo...

In our iOS project at root level we have package.json with:

{
  "name": "xxx",
  "version": "1.0.0",
  "dependencies": {
    "apollo": "^1.6.0"
  },
  "devDependencies": {},
  "repository": {
    "type": "git",
    "url": "git+https://github.com/xxx/xxx.git"
  },
  "keywords": [],
  "author": "",
  "license": "UNLICENSED",
  "private": true,
  "bugs": {
    "url": "https://github.com/xxx/xxx/issues"
  },
  "homepage": "https://github.com/xxx/xxx#readme"
}

Note it required Apollo 1.6.0.

We have latest (0.9.2) Apollo pod integrated into our project:

➜  xxx git:(apollo-tweaks)  cat Podfile.lock | grep Apollo
  - Apollo (0.9.2):
    - Apollo/Core (= 0.9.2)
  - Apollo/Core (0.9.2)
  - Apollo
    - Apollo
  Apollo: 39d1adfceb6f262fc58286ec9425fd7c332877fb

We do have code generation build step per recommendation here:

APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"

if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
  echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
  exit 1
fi

cd "${SRCROOT}/${TARGET_NAME}"

$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=./GraphQL/schema.json ./GraphQLAPI.swift

And when the build step runs it actually downgrades apollo npm package to 1.2.0:

cd /Users/yas/code/xxx/xxx
Queries: ./GraphQL/xxx.graphql
+++ get_installed_version
++++ /Users/yas/code/xxx/node_modules/.bin/apollo -v
+++ version='apollo/1.6.0 darwin-x64 node-v10.7.0'
+++ [[ 0 -eq 0 ]]
+++ echo 'apollo/1.6.0 darwin-x64 node-v10.7.0'
++ INSTALLED_APOLLO_CLI_VERSION='apollo/1.6.0 darwin-x64 node-v10.7.0'
++ are_versions_compatible apollo/1.6.0 darwin-x64 node-v10.7.0 1.2.0
+++ cut -d/ -f2
+++ cut -d. -f1-2
+++ cut -d/ -f2
+++ cut -d. -f1-2
++ [[ 1.6 == \d\a\r\w\i\n\-\x\6\4 ]]
++ echo 'The version of Apollo.framework in your project requires Apollo CLI 1.2.0,   but apollo/1.6.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...'
The version of Apollo.framework in your project requires Apollo CLI 1.2.0,   but apollo/1.6.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...
++ install_apollo_cli
++ set -e
++ npm install --prefix /Users/yas/code/xxx [email protected]
+ [email protected]
added 8 packages from 10 contributors, removed 2 packages, updated 9 packages and audited 2124 packages in 12.714s
found 0 vulnerabilities

++ set +e
++ exec /Users/yas/code/xxx/node_modules/.bin/apollo codegen:generate --queries=./GraphQL/xxx.graphql --schema=./GraphQL/schema.json ./GraphQLAPI.swift
 ›   Warning: apollo update available from 1.2.0 to 1.6.0
[?25l[15:43:18] Scanning for GraphQL queries [started]

I assume this is not an intentional behavior, is it?

Most helpful comment

downgraded to apollo-ios pod 0.9.3
then npm install -g [email protected]
works for me for now

All 38 comments

This is in fact intentional behavior. Because changes to the generated code could break the installed version of the Apollo iOS framework, we pin the CLI version to the version it is known to work with.

We've always done this for apollo-codegen, but I can see how it's becoming inconvenient with the move to the apollo CLI because codegen is just one of the features. You can always use a newer global install for other features of course. But we should probably find a way to only depend on the version of apollo-codegen-swift.

Gotcha. Shouldn't it pin a more recent version of Apollo CLI maybe? It pins 1.2.0 while there is already 1.6.0. And I'm using latest Apollo iOS pod (0.9.2) which was released just a couple of days ago.

Also, it looks like it reruns npm install ... on every build I do even though it has installed 1.2.0 already. This is what I see in logs on every build:

+++ get_installed_version
++++ /Users/yas/code/xxx/node_modules/.bin/apollo -v
 ›   Warning: apollo update available from 1.2.0 to 1.6.0
+++ version='apollo/1.2.0 darwin-x64 node-v10.7.0'
+++ [[ 0 -eq 0 ]]
+++ echo 'apollo/1.2.0 darwin-x64 node-v10.7.0'
++ INSTALLED_APOLLO_CLI_VERSION='apollo/1.2.0 darwin-x64 node-v10.7.0'
++ are_versions_compatible apollo/1.2.0 darwin-x64 node-v10.7.0 1.2.0
+++ cut -d/ -f2
+++ cut -d. -f1-2
+++ cut -d/ -f2
+++ cut -d. -f1-2
++ [[ 1.2 == \d\a\r\w\i\n\-\x\6\4 ]]
++ echo 'The version of Apollo.framework in your project requires Apollo CLI 1.2.0,   but apollo/1.2.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...'
The version of Apollo.framework in your project requires Apollo CLI 1.2.0,   but apollo/1.2.0 darwin-x64 node-v10.7.0 seems to be installed. Installing...
++ install_apollo_cli
++ set -e
++ npm install --prefix /Users/yas/code/xxx [email protected]
+ [email protected]
updated 1 package and audited 2124 packages in 28.9s
found 0 vulnerabilities

Let me know if you would prefer me to open a separate issue for this.

++ [[ 1.2 == \d\a\r\w\i\n-\x\64 ]]

@martijnwalraven

The above is the problem. We have the exact same issue and had to change the script by just returning true from this function:

are_versions_compatible() {
    return 0
    # [[ "$(cut -d/ -f2 <<< $1 | cut -d. -f1-2)" == "$(cut -d/ -f2 <<< $2 | cut -d. -f1-2)" ]]
}

This is affecting me (everybody really) too, hopefully it can be fixed soon and merged.

Me too. hope things get better🙇‍♂️

This should be fixed in Apollo iOS 0.9.3.

Me too. I can still repro this on 0.9.3. Thanks!

@ynie What do you mean when you say you can repro this?

@martijnwalraven here's my output:

Showing All Messages
warning: The version of Apollo.framework in your project requires Apollo CLI 1.8.x, but apollo/1.2.0 darwin-x64 node-v8.9.4 seems to be installed.

note: Installing [email protected] in your project directory to avoid version conflicts...

npm WARN saveError ENOENT: no such file or directory, open '/Users/xxxx/xxx/xxxx/xxxx/package.json'

npm WARN enoent ENOENT: no such file or directory, open '/Users/xxxx/xxxx/xxx/xxx/package.json'

npm WARN Durian No description

npm WARN Durian No repository field.

npm WARN Durian No README data

npm WARN Durian No license field.

updated 1 package in 2.457s

++ npx --no-install apollo codegen:generate '--queries=./GraphQL/my_repos.graphql

./GraphQL/dashboard_info.graphql

./GraphQL/me_info.graphql

./GraphQL/issue_timeline.graphql' --schema=GraphQL/github_ql_schema.json GraphQL/GitHubGraphQLAPI.swift

› Warning: apollo update available from 1.2.0 to 1.5.0

[?25l[18:01:30] Scanning for GraphQL queries [started]

[18:01:30] Scanning for GraphQL queries (4 found) [title changed]

[18:01:30] Scanning for GraphQL queries (4 found) [completed]

[18:01:30] Loading GraphQL schema [started]

[18:01:30] Loading GraphQL schema [completed]

[18:01:30] Parsing GraphQL schema [started]

[18:01:30] Parsing GraphQL schema [completed]

[18:01:30] Generating query files [started]

[18:01:30] Generating query files with 'swift' target [title changed]

[18:01:30] Generating query files with 'swift' target - wrote 1 files [title changed]

[18:01:30] Generating query files with 'swift' target - wrote 1 files [completed]

@ynie Can you check if [email protected] has indeed been installed in your project directory (under node_modules)?

@martijnwalraven Thanks! How do I check that?

@ynie Look under node_modules/apollo in your project directory, and check the version in package.json.

image

@ynie That seems fine. Can you run npx --no-install apollo --version in your project directory to check if it picks up the local version?

apollo (master) $ npx --no-install apollo --version
› Warning: apollo update available from 1.2.0 to 1.5.0
apollo/1.2.0 darwin-x64 node-v8.9.4

Thanks! That's what I got.

@ynie That's really weird! npx --no-install apollo should pick up the local version over the global one, I just checked. Can you run which apollo to see where the global version has been installed?

That will be
ynie@MBP apollo (master) $ which apollo
/usr/local/bin/apollo

We have the same issue. The local version is not picked up and we all had to install it globally even on CircleCI to pick it up

@ynie @vandadnp Can you try npx --version? I re-checked, and it does pick up the local version for me.

@martijnwalraven here is my output for all 3 commands:

➜ npx --version                    
9.7.1
➜ npx --no-install apollo --version
apollo/1.8.3 darwin-x64 node-v8.11.4
➜ which apollo
/usr/local/bin/apollo

@vandadnp Are you running npx --no-install apollo --version from your project directory, the directory with node_modules with apollo/ and .bin/apollo in it?

@martijnwalraven yes I am running it from the root directory of our project, where node_modules is located

@vandadnp Then I'm really out of ideas, because it does work for me :( Hopefully someone can figure out what is going on here.

bogon$ npx --version
9.7.1
bogon$ npx --no-install apollo --version
› Warning: apollo update available from 1.8.3 to 1.9.1
apollo/1.8.3 darwin-x64 node-v9.11.1

I met the same issue. How to fix it?

I'm facing the same issue :(

Abdullahs-iMac:Haraj Swift abdullahumer$ npx -version
6.4.1
Abdullahs-iMac:Haraj Swift abdullahumer$ npx --no-install apollo --version
 ›   Warning: apollo update available from 1.8.3 to 1.9.2
apollo/1.8.3 darwin-x64 node-v8.11.3
Abdullahs-iMac:Haraj Swift abdullahumer$ 
➜  git:(master) ✗ which apollo
/usr/local/bin/apollo
➜  git:(master) ✗ npx --version
6.4.1
➜  git:(master) ✗ npx --no-install apollo --version
 ›   Warning: apollo update available from 1.8.3 to 1.9.2
apollo/1.8.3 darwin-x64 node-v8.6.0

Temporary solution: Upgrade apollo to the latest version and manually reinstall the local modules in project directory

$ npm install -g apollo
$ rm -rf node_modules
$ pod install

@hao-li when i do that i receive the following error:
apollo update available from 1.8.3 to 1.9.2

Have you run npm install -g apollo? I had a local version of apollo in my node_modules, but it seems like it wants to update the version in /usr/local/lib/node_modules/apollo

@Dfmarulanda
In my case it seems that the version under the project is behind the global version.
So remove the project version and reinstall it, it should install the latest version directly.

By running npm install -g apollo, you can ensure that the global version is also up to date, so the two are consistent.

I have updated the temporary solution in the previous answer and added this step, thanks to @jessieserrino

I'm seeing this error "Apollo CLI requires Node 8 or higher, but v7.4.0 seems to be installed", when trying to build my project. I've checked my node version in my iOS project folder and globally and it is 8.x. I'm using latest version of apollo client for ios ~ 0.9.4. And apollo CLI ~ apollo/2.1.0 darwin-x64 node-v8.11.1. Please advise compatible versions or steps for resolution.

downgraded to apollo-ios pod 0.9.3
then npm install -g [email protected]
works for me for now

Got below in the log and build is fail.

+++ get_installed_version
++++ /Users/MAC/Desktop/Demo/node_modules/.bin/apollo -v
› Warning: apollo update available from 1.2.0 to 2.1.8
+++ version='apollo/1.2.0 darwin-x64 node-v10.4.0'
+++ [[ 0 -eq 0 ]]
+++ echo 'apollo/1.2.0 darwin-x64 node-v10.4.0'
++ INSTALLED_APOLLO_CLI_VERSION='apollo/1.2.0 darwin-x64 node-v10.4.0'
++ are_versions_compatible apollo/1.2.0 darwin-x64 node-v10.4.0 1.2.0
+++ cut -d/ -f2
+++ cut -d. -f1-2
+++ cut -d/ -f2
+++ cut -d. -f1-2
++ [[ 1.2 == \d\a\r\w\i\n-\x\64 ]]
++ echo 'The version of Apollo.framework in your project requires Apollo CLI 1.2.0, but apollo/1.2.0 darwin-x64 node-v10.4.0 seems to be installed. Installing...'
The version of Apollo.framework in your project requires Apollo CLI 1.2.0, but apollo/1.2.0 darwin-x64 node-v10.4.0 seems to be installed. Installing...
++ install_apollo_cli
++ set -e
++ npm install --prefix /Users/MAC/Desktop/Demo [email protected]
npm WARN saveError ENOENT: no such file or directory, open '/Users/MAC/Desktop/Demo/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/MAC/Desktop/Demo/package.json'
npm WARN Demo No description
npm WARN Demo No repository field.
npm WARN Demo No README data
npm WARN Demo No license field.

  • [email protected]
    updated 1 package and audited 8369 packages in 4.265s
    found 0 vulnerabilities

++ set +e
++ exec /Users/MAC/Desktop/Demo/node_modules/.bin/apollo codegen:generate --queries=./Demo/GraphQL/GraphQueries.graphql --schema=schema.json API.swift
› Warning: apollo update available from 1.2.0 to 2.1.8
[18:25:57] Scanning for GraphQL queries [started]
[18:25:57] Scanning for GraphQL queries (1 found) [title changed]
[18:25:57] Scanning for GraphQL queries (1 found) [completed]
[18:25:57] Loading GraphQL schema [started]
[18:25:57] Loading GraphQL schema [failed]
[18:25:57] → ENOENT: no such file or directory, open '/Users/MAC/Desktop/Demo/schema.json'
Error: ENOENT: no such file or directory, open '/Users/MAC/Desktop/Demo/schema.json'

downgraded to apollo-ios pod 0.9.3
then npm install -g [email protected]
works for me for now

It's worked for me

Sounds like this was resolved earlier this year - I'm going to close this issue out, but please open a new issue if you're still having problems!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ashiemke picture ashiemke  ·  5Comments

Dmurph24 picture Dmurph24  ·  4Comments

wnagrodzki picture wnagrodzki  ·  4Comments

designatednerd picture designatednerd  ·  3Comments

MrAlek picture MrAlek  ·  3Comments