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

Binary install does not upgrade rover when npm version is upgraded #1563

Closed
justus-lattice opened this issue Apr 5, 2023 · 12 comments · Fixed by #1932
Closed

Binary install does not upgrade rover when npm version is upgraded #1563

justus-lattice opened this issue Apr 5, 2023 · 12 comments · Fixed by #1932
Labels
bug 🐞 triage issues and PRs that need to be triaged

Comments

@justus-lattice
Copy link

justus-lattice commented Apr 5, 2023

Description

Rover does not upgrade to the latest binary whenever you upgrade from a previous npm version.

Steps to reproduce

  • npm init
  • npm install @apollo/rover@0.10.0
  • npm install @apollo/rover@0.11.1
  • node_modules/.bin/rover --version

Expected result

It should return Rover 0.11.1.

Actual result

Rover 0.10.0

Environment

Rover Info:
Version: 0.10.0
Install Location: /code/rover-sandbox/node_modules/binary-install/node_modules/.bin/rover
OS: Mac OS 12.6.4 [64-bit]
Shell: /bin/zsh

@justus-lattice justus-lattice added bug 🐞 triage issues and PRs that need to be triaged labels Apr 5, 2023
@maschwenk
Copy link

maschwenk commented Apr 5, 2023

image

https://github.com/EverlastingBugstopper/binary-install/blob/main/packages/binary-install/index.js#L54-L66

More specifically I think the issue is in binary-install package, or Rover's use of it, because the binary install directory is stable across different versions of the Rover node module, so it keeps calling exists() and thinking it's already there

@maschwenk
Copy link

So I think the binary path needs to be keyed off the version of the binary or something similar, doesn't seem like an issue with the binary-install package

@EverlastingBugstopper EverlastingBugstopper self-assigned this Apr 7, 2023
@abernix
Copy link
Member

abernix commented Apr 25, 2023

Hi! Thanks for opening this issue! I'm not able to reproduce the problem that you're encountering with the steps that you've included above:

image

As you can see, I'm correctly receiving the version of Rover that I requested.

I'm using Node v18.15.0 and npm version v9.5.0:

image

I don't see any recent bug that could have introduced behavior like this and I'm surprised that this hasn't been a problem more broadly, so I suspect there must be something more nuanced here.

I think this could take a bit of back and forth to get to the bottom of, but a few things that could help drive progress in the near term:

  • Can you confirm that your reproduction instructions are sufficient to reproduce this in a fresh reproduction? (Can anyone else reproduce using just the steps above?)
  • Assuming that you're encountering this in a larger project than this reproduction, could you verify that there is only a single version of @apollo/rover in your dependency tree? Running npm ls @apollo/rover could help highlight whether there are multiple competing dependencies that might be stomping on the (single) ./node_modules/.bin/rover binary.
  • As a shorter-term work-around, is there a way you could leverage a different method of installing rover? For example, we have an example of installing rover without npm with the pinned-version instructions that lives in the Rover documentation. You'd want to avoid calling ./node_modules/.bin/rover at that point and make sure to just use the rover that is installed in the system's PATH, but this might help unblock you?

@kleinsch
Copy link

kleinsch commented Apr 25, 2023

If you upgrade, you won't get the version of Rover you requested. That's the problem we're facing

Attempts to have devs upgrade the @apollo/rover package to 0.11.1, resulted in no change to the binary because of a cached version of their old binary, and new installs grabs the latest binary

nkleinschmidt@NKleinschmidt rovertest % npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (rovertest) 
version: (1.0.0) 
description: 
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /private/tmp/rovertest/package.json:

{
  "name": "rovertest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes) 
nkleinschmidt@NKleinschmidt rovertest % npm install @apollo/rover@0.9.0    

added 33 packages, and audited 34 packages in 1s

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
nkleinschmidt@NKleinschmidt rovertest % ./node_modules/.bin/rover --version
Rover 0.9.0
nkleinschmidt@NKleinschmidt rovertest % cat ./node_modules/@apollo/rover/package.json | head -n 3
{
  "name": "@apollo/rover",
  "version": "0.9.0",
nkleinschmidt@NKleinschmidt rovertest % npm install @apollo/rover@0.10.0                     

changed 1 package, and audited 34 packages in 232ms

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
nkleinschmidt@NKleinschmidt rovertest % cat ./node_modules/@apollo/rover/package.json | head -n 3
{
  "name": "@apollo/rover",
  "version": "0.10.0",
nkleinschmidt@NKleinschmidt rovertest % ./node_modules/.bin/rover --version                  
Rover 0.9.0

@abernix
Copy link
Member

abernix commented Apr 26, 2023

@kleinsch Thanks for that detail! I can confirm the same behavior locally using the additional step of upgrading.

@justus-lattice Can you confirm that this is the same problem that you're reporting? Looking at the nuance in your text about upgrading, I'll assume that to be the case. If you agree, do you mind updating your reproduction steps in your original post to include the additional step of updating to another version?

@EverlastingBugstopper The assessment above by @maschwenk does seem to be the root cause in that, if the "exists" detects that it is there, it doesn't actually write over it with the new version. Not clobbering the existing binary totally makes sense! I could imagine that the comparison of the --version output would be one solution, but that doesn't actually apply as a solution since binary-install is meant to be a multi-purpose OSS npm package that works for all binaries. In that spirit, perhaps it is best that the installDirectory generation itself (within binary-install) be keyed as ${packageName}--${package-json-version} similar to how @maschwenk has suggested above?

@abernix
Copy link
Member

abernix commented Apr 26, 2023

@kleinsch, @maschwenk, @justus-lattice — just to make sure you catch my suggestion from above while we get to the bottom of this: there is a work-around in a non-npm sense that you can use: you can remove @apollo/rover and instead install it with the normal installer which absolutely does support pinning the version (docs linked above)

@justus-lattice justus-lattice changed the title Binary install does not respect the npm package version Binary install does not upgrade rover when npm version is upgraded Apr 26, 2023
@justus-lattice
Copy link
Author

@abernix Yes that is the same problem I am reporting, apologize for the incorrect reproduction steps. I have updated the original description

@maschwenk
Copy link

@kleinsch Thanks for that detail! I can confirm the same behavior locally using the additional step of upgrading.

@justus-lattice Can you confirm that this is the same problem that you're reporting? Looking at the nuance in your text about upgrading, I'll assume that to be the case. If you agree, do you mind updating your reproduction steps in your original post to include the additional step of updating to another version?

@EverlastingBugstopper The assessment above by @maschwenk does seem to be the root cause in that, if the "exists" detects that it is there, it doesn't actually write over it with the new version. Not clobbering the existing binary totally makes sense! I could imagine that the comparison of the --version output would be one solution, but that doesn't actually apply as a solution since binary-install is meant to be a multi-purpose OSS npm package that works for all binaries. In that spirit, perhaps it is best that the installDirectory generation itself (within binary-install) be keyed as ${packageName}--${package-json-version} similar to how @maschwenk has suggested above?

Yep, I think the simple fix is just keying the folder by the version of the package. You'll accumulate old version of the binary over time but I think that's better than the alternative.

@kleinsch, @maschwenk, @justus-lattice — just to make sure you catch my suggestion from above while we get to the bottom of this: there is a work-around in a non-npm sense that you can use: you can remove @apollo/rover and instead install it with the normal installer which absolutely does support pinning the version (docs linked above)

For sure, but the convenience of not having to have a bespoke step is nice. Particularly if you want to be able to have the same behavior across mac/linux/dev/CI.

@LongLiveCHIEF
Copy link
Contributor

This would be a bug we need to o pen in https://github.com/EverlastingBugstopper/binary-install instead of rover, since the logic for this exists in that package.

@maschwenk
Copy link

@LongLiveCHIEF y'all have already inlined that dependency into your library. For reference I have just done the following for my purposes:

this.installDirectory = join(
      __dirname,
      '..',
      'node_modules',
      '.bin',
      `${this.roverBinaryName}-v${roverVersionFromConfig}`,
    );

where I just key the install location on the version name. pretty simple.

@LongLiveCHIEF
Copy link
Contributor

There's a world of difference between "behaves as expected automatically" and "simple to implement a workaround". It may be simple, but it's also an extra step to be documented for others, and devs aren't great at reading documentation.

Now add a few dozen devs to the effort, and you'll have problems frequently with devs saying things aren't working because they missed the instructions to patch a dependency, especially when projects of this nature typically install/update and startup without having to do any manual setup.

@maschwenk
Copy link

To be clear we had to fork @apollo/rover internally for this issue and

so just sharing that that's what we did to get around this issue. What I'm saying is that y'all have already inlined binary-install into your library as of this PR

so if y'all want to make changes here, you can just do it! no dependency on binary-install anymore.

jonathanrainer added a commit that referenced this issue Jul 15, 2024
# [0.24.0]

> Important: 1 potentially breaking change below, indicated by **❗
BREAKING ❗**

## ❗ BREAKING ❗

- **Removed the deprecated `plain` and `json` options for `--output` -
@dylan-apollo PR
[#1804](#1804

The `--output` option is now only for specifying a file to write to. The
`--format` option should be used to specify the format of the output.

## 🚀 Features

- **Return the name of the linting rule that is violated, as well as the
code - @jonathanrainer PR
[#1907](#1907

Originally only the message from the linting violation was included in
the response, but now it also includes the name of the specific linting
rule to aid debugging

- **Use the Router's `/health?ready` endpoint to check readiness -
@nmoutschen PR
[#1939](#1939

Previously `rover dev` used a simple query to establish readiness, but
this did not allow for router customizations.

- **Adding architecture and OS metrics - @aaronArinder PR
[#1947](#1947

Allows us to track the Operating Systems and Architectures in use by our
users, this will give us more information as to where to focus support
efforts

- **Allow `aarch64` macOS to pull correct `supergraph` binaries where
available - @jonathanrainer PR
[#1971](#1971

We recently started publishing `supergraph` binaries for `aarch64`, so
if they are available Rover will use them in preference to x86_64
binaries.

## 🐛 Fixes

- **Don't panic if the telemetry client cannot be initialised -
@dylan-apollo PR
[#1897](#1897) - Issue
[#1893](#1893
- **Rename `.cargo/config` to `.cargo/config.toml` - @jonathanrainer PR
[#1921](#1921
- **Fix `pnpm` installs by moving the binary download location -
@jonathanrainer PR
[#1927](#1927) - Issue
[#1881](#1881
  
After we inlined the `binary-install` dependency in v0.23.0 this changed
where the downloaded binary was stored when using `pnpm`. This caused
users running the binary to enter an infinite loop. This moves the
binary to a new location which avoids this.

- **Don't panic on file watcher errors - @nmoutschen PR
[#1935](#1935

Instead of panicking when errors occur watching files return those
errors gracefully to the user.

- **Store binaries with version numbers attached so upgrades are
possible - @jonathanrainer PR
[#1932](#1932) - Issue
[#1563](#1563

When downloading binaries via `npm` they were always stored as `rover`
despite the version. As such, when a new version came out the upgrade
would fail. This now doesn't happen, as binaries are stored with their
versions number in the name.

- **Ensure correct URL is used if `subgraph_url` and `routing_url` are
provided in a supergraph schema - @jonathanrainer PR
[#1948](#1948) - Issue
[#1782](#1782
- **Let `--output` accept paths with missing intermediate directories -
@jonathanrainer PR
[#1944](#1944) - Issue
[#1787](#1787
- **Allow `rover dev` to read Federation Version from supergraph schema
- @jonathanrainer PR
[#1950](#1950) - Issue
[#1735](#1735

The Federation version could be set in the supegraph schema but was
being ignored by `rover dev`. It now is taken into account, along with
the overriding environment variable.

- **Stop .exe being printed after Federation version during composition
- @jonathanrainer PR
[#1951](#1951) - Issue
[#1390](#1390
- **Reinstate support for `glibc` 2.17 - @jonathanrainer PR
[#1953](#1953

In resolving the issues with CentOS 7 we accidentally removed support
for `glibc` 2.17, this has now been restored

- **Be more lenient about `supergraph` binary versions - @dylan-apollo
PR [#1966](#1966

In resolving #1390, we were too restrictive in what counted as a valid
version. This restores the correct behaviour

- **Set `package.json` to a stable version when testing NPM Installers -
@jonathanrainer PR
[#1967](#1967

When testing whether our NPM installers worked correctly we were trying
to download the latest `rover` binary. On release PRs, where the binary
didn't yet exist, this was causing problems.

- **Fix mocking of calls to Orbiter in Installer tests - @jonathanrainer
PR [#1968](#1968
- **Remove noisy errors from intermediate composition states -
@aaronArinder PR
[#1956](#1956
  
When `rover dev` composes multiple subgraphs it does so one at a time.
As such if there are dependencies there can be noisy ephemeral errors,
this fixes that by waiting until all subgraphs are added before trying
composition.

## 🛠 Maintenance

- **Update GitHub CircleCI Orb to v2.3.0 - @Geal PR
[#1831](#1831
- **Update plugins to Fed 2.7 and Router 1.43.0 - @smyrick PR
[#1877](#1877
- **Update CODEOWNERS - @dotdat PR
[#1890](#1890

  Make Betelgeuse the primary owners of the Rover repository

- **Update lychee-lib to v0.15 - @dotData PR
[#1902](#1902
- **Add tests and provide status codes as part of linter errors -
@dotdat PR [#1903](#1903
- **Add nix files to .gitignore - @aaronArinder PR
[#1908](#1908
- **Update apollographql/router to v1.47.0 - @aaronArinder PR
[#1841](#1841
- **Update apollographql/federation-rs to v2.7.8 - @aaronArinder PR
[#1746](#1746
- **Update node.js to v20 - @aaronArinder PR
[#1778](#1778
- **Update Rust to v1.76.0 and the Rust CircleCI Orb to v1.6.1 -
@aaronArinder PR
[#1788](#1788
- **Update serial_test to v3 - @jonathanrainer PR
[#1836](#1836
- **Update which to v6 - @jonathanrainer PR
[#1835](#1835
- **Update apollographql/federation-rs to v2.8.0 - @aaronArinder PR
[#1909](#1909
- **Update tar to v6.2.1 - @aaronArinder PR
[#1888](#1888
- **Update tar to v7 - @aaronArinder PR
[#1914](#1914
- **Update node.js packages - @aaronArinder PR
[#1830](#1830

Includes `eslint` to v8.57.0, `node.js` to v20.14.0, `nodemon` to
v3.1.2, `npm` to v10.8.1 and `prettier` to v3.3.0

- **Update Rust to v1.78.0 - @aaronArinder PR
[#1912](#1912
- **Update apollographql/router to v1.48.0 - @aaronArinder PR
[#1917](#1917
- **Update zip to v2 - @jonathanrainer PR
[#1916](#1916
- **Update eslint to v9.4.0 - @dotdat PR
[#1913](#1913
- **Update hyper to v1.0 - @dotdat PR
[#1789](#1789
- **Add tests for socket names - @jonathanrainer PR
[#1918](#1918
  
In future dependency upgrades we want to ensure that behaviour around
socket naming works as expected, so add a test to ensure that.

- **Update rust packages - @jonathanrainer PR
[#1755](#1755

Consolidates updates of pre-1.0 rust crates, check PR for full details
of crates updated

- **Update notify to v6 - @jonathanrainer PR
[#1603](#1603
- **Include cargo-deny checks on PRs - @jonathanrainer PR
[#1910](#1910

Now we can check for licences that don't correspond to our allowed list
and pick up on dependency issues live on PRs

- **Pin node.js dev dependencies - @aaronArinder PR
[#1923](#1923
- **Allow 0BSD licence - @aaronArinder PR
[#1924](#1923
- **Update interprocess to v2 - @dotdat PR
[#1915](#1915
- **Update apollographql/router to v1.48.1 - @dotdat PR
[#1926](#1926
- **Update Rust to v1.79.0 - @jonathanrainer PR
[#1931](#1931
- **Update git2 to v0.19 - @jonathanrainer PR
[#1930](#1930
- **Update node.js packages - @jonathanrainer PR
[#1929](#1929

Includes `@eslint/compat` to v1.1.0, `eslint` to v9.5.0, `graphql` to
v16.8.2 and `prettier` to v3.3.2

- **Migrate CI to use manylinux rather than CentOS 7 - @jonathanrainer
PR [#1952](#1952

As CentOS 7 has now entered End-of-Life, migrate our CI to use a
different Linux distribution.

- **Update apollographql/router to v1.49.1 - @jonathanrainer PR
[#1933](#1933
- **Update apollographql/federation-rs to v2.8.2 - @jonathanrainer PR
[#1934](#1934
- **Update node.js packages - @jonathanrainer PR
[#1940](#1940

Includes `eslint` to v9.6.0, `node.js` to v20.15.0, `nodemon` to v3.1.4,
`graphql` to v16.9.0

- **Fix clippy warnings - @loshz PR
[#1955](#1955
- **Allow integration tests to accept a pre-compiled binary -
@jonathanrainer PR
[#1957](#1957
- **Run macOS x86_64 integration tests in GitHub Actions - @nmoutschen
PR [#1958](#1958
  
Due to CircleCI's deprecation of x86_64 macOS executors use GitHub
Actions to still run our tests on this architecture

- **Add smoke tests for `rover dev` - @jonathanrainer PR
[#1961](#1961
- **Update apollographql/router to v1.50.0 - @jonathanrainer PR
[#1954](#1954
- **Trigger GitHub Actions from CircleCI - @nmoutschen PR
[#1959](#1959
- **Add docs team to CODEOWNERS - @aaronArinder PR
[#1965](#1965
- **Fix up Release CI and explicitly add tokio `rt-multi-thread flag` -
@jonathanrainer PR
[#1972](#1972
- **Add context to auth output when saving an API Key - @loshz PR
[#1974](#1974


## 📚 Documentation

- **Minor update to README.md - @tratzlaff PR
[#1880](#1880

  Fixes use of numbered lists in the README.md 

- **Remove failing/redundant links from docs - @dotdat PR
[#1894](#1894
- **Update docs style - @Meschreiber PR
[#1883](#1883

  Update formatting and admonitions to most recent conventions.

- **Update frontmatter - @Meschreiber PR
[#1898](#1898

  Updates title casing and adds metadata to subtitles

- **Clarify `subgraph publish` can only create variants not graphs -
@Meschreiber PR
[#1938](#1938
- **Make example using `-` instead of filepath clearer - @aaronArinder
PR [#1963](#1963
- **Update Router terminology - @Meschreiber PR
[#1925](#1925

Update the uses of Apollo Router to GraphOS Router or Apollo Router Core
where necessary
- **Update documentation to make it clear we collect CPU Architecture,
per command - @aaronArinder PR
[#1964](#1964
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 triage issues and PRs that need to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants