apollographql / rover

The CLI for Apollo GraphOS
https://rover.apollo.dev
Other
405 stars 85 forks source link

supergraph compose with --skip-update fails #1254

Open dhay opened 2 years ago

dhay commented 2 years ago

Description

When attempting to compose a supergraph, if add the --skip-update flag, the composition fails. It works correctly when the flag is omitted:

Steps to reproduce


$ ./rover-apple-darwin/dist/rover supergraph compose --config supergraph.yaml > /dev/null
installing plugin 'supergraph-0' for 'rover supergraph compose'...
downloading supergraph from https://rover.apollo.dev/tar/supergraph/x86_64-apple-darwin/latest-0
supergraph-0 was successfully installed. Great!
composing supergraph with Federation v0.36.1.

$ ./rover-apple-darwin/dist/rover supergraph compose --skip-update --config supergraph.yaml > /dev/null
composing supergraph with Federation v0.36.1.
error: Failed to execute command

Caused by:
    No such file or directory (os error 2)

$ ./rover-apple-darwin/dist/rover supergraph compose --config supergraph.yaml > /dev/null
composing supergraph with Federation v0.36.1.

Expected result

Passing the --skip-update shouldn't have any bearing on whether the composition succeeds or fails.

Actual result

Received the error:

error: Failed to execute command

Caused by:
    No such file or directory (os error 2)

Environment

$ ./rover-apple-darwin/dist/rover info Rover Info: Version: 0.8.1 Install Location: /home/me/rover-apple-darwin/dist/rover OS: Mac OS 12.4.0 [64-bit] Shell: /usr/local/bin/bash

EverlastingBugstopper commented 2 years ago

Hi @dhay - thanks for the report.

I'm unable to reproduce this issue:

$ cargo rover supergraph compose --config ./file.yaml > /dev/null
    Finished dev [unoptimized + debuginfo] target(s) in 0.20s
     Running `/home/a/work/rover/target/debug/rover supergraph compose --config ./file.yaml`
composing supergraph with Federation v2.0.5.
$ cargo rover supergraph compose --config ./file.yaml --skip-update > /dev/null
    Finished dev [unoptimized + debuginfo] target(s) in 0.20s
     Running `/home/a/work/rover/target/debug/rover supergraph compose --config ./file.yaml --skip-update`
composing supergraph with Federation v2.0.5.

What is the output of ls ~/.rover/bin after running the first command?

dhay commented 2 years ago

What is the output of ls ~/.rover/bin after running the first command?

$ ls ~/.rover/bin
supergraph-v0.36.1

We're still using Federation 1...perhaps the issue has been fixed in the 2.x plugin? This is the version that rover automatically downloaded.

EverlastingBugstopper commented 2 years ago

hmmmm, no i don't think that's it. i wish the error message here included what file it was trying to read from. i'll get a PR up to at least get a better error message here and we can try troubleshooting.

for now as a workaround - maybe try running rover install and see if that fixes up your issue.

dhay commented 2 years ago

Running rover install didn't seem to help any.

The reason I was thinking it might be a Federation 1 vs. 2 thing is that your output included composing supergraph with Federation v2.0.5....or maybe you're using a different version of rover?

EverlastingBugstopper commented 2 years ago

nah - rover supergraph compose works with multiple versions of federation, it downloads the correct version at runtime. here's my output when i don't include any @link directives in my subgraphs:

$ rover supergraph compose --config ./supergraph.yaml > /dev/null
composing supergraph with Federation v0.36.1.
EverlastingBugstopper commented 2 years ago

also - after running rover install - does rover appear in ~/.rover/bin? and can you just call rover directly without referring to the binary path itself? as in - instead of ./dist/rover just run rover since it's in your PATH?

dhay commented 2 years ago

Weird...if I have ~/.rover/bin in my path, the error goes away...why should that matter?

EverlastingBugstopper commented 2 years ago

so the error you're running into originates from this line which is attempting to run the binary that it found from this function - (src of that function). since you passed --skip-update, it tries to find your currently installed plugins here and here, and then it even asserts that the file exists here. so... i'm really not sure why it doesn't like it when it's not in your PATH since we should be handing it a fully qualified path to the binary, and it doesn't error out when it asserts that file exists, only when you actually try to run it.

RyanWhite25 commented 1 year ago

We ran into this issue today (federation v2) whilst trying to bundle rover & the supergraph plugin in an AWS Lambda layer. Here's a step-by-step to reproduce it on a container running ubuntu, in case anyone's struggling to reproduce the issue:

ROVER_VERSION="v0.9.1"

# Test Setup
mkdir /tmp/composeTest

docker run -it \
  -v /tmp/composeTest/:/composeTest/ \
  -w /composeTest/ \
  -e ROVER_VERSION=$ROVER_VERSION \
  ubuntu:latest

apt-get update && apt-get install curl -y

mkdir -p ./rover/
curl --create-dirs -o ./rover/rover -sSL "https://github.com/apollographql/rover/releases/download/${ROVER_VERSION}/rover-${ROVER_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
tar -xvf ./rover/rover -C ./rover/

export PATH=$PATH:/composeTest/rover/dist

# Schema
mkdir ./files

cat > ./files/test.gql <<- EOM
type Query {
  lookup(foo: String!): LookupResult!
}

type LookupResult {
  name: String!
}
EOM

cat > ./files/supergraph.yml <<- EOM
federation_version: 2
subgraphs:
  test:
    routing_url: https://not-a-url.com/
    schema:
      file: /composeTest/files/test.gql
EOM

# Execute 
rover supergraph compose --elv2-license accept --config /composeTest/files/supergraph.yml
# ...composing supergraph with Federation v2.1.2...
# Succeeds. Downloads plugin to /root/.rover/bin/supergraph-v2.1.2

# Execute with --skip-update set
rover supergraph compose --skip-update --elv2-license accept --config /composeTest/files/supergraph.yml
# ...composing supergraph with Federation v2.1.2...
# error: Failed to execute command
# 
# Caused by:
#     No such file or directory (os error 2)

Updating $PATH with the plugin location described above seems to fix it, as does storing the supergraph plugin alongside rover in the same directory.