'Can anyone tell me what's the error in this code segment I even tried updating the project ID as said in the error and it also gave me an error

gcloud iam roles update editor --project $DEVSHELL_PROJECT_ID --file new-role-definition.yaml
                                
ERROR: (gcloud.iam.roles.update) INVALID_ARGUMENT: The name in the request (projects/qwiklabs-gcp-01-7bc9f94ad9bd/roles/editor) and the name in the role (projects/[PROJECT_ID]/roles/editor) must match.

gcloud iam roles update editor --project $DEVSHELL_qwiklabs-gcp-01-7bc9f94ad9bd --file new-role-definition.yaml              

ERROR: (gcloud.iam.roles.update) argument --project: expected one argument
Usage: gcloud iam roles update ROLE_ID (--organization=ORGANIZATION | --project=PROJECT_ID) [optional flags]
  optional flags may be  --add-permissions | --description | --file | --help |
                         --organization | --permissions | --project |
                         --remove-permissions | --stage | --title


Solution 1:[1]

$DEVSHELL_qwiklabs-gcp-01-7bc9f94ad9bd doesn't seem to be defined your shell?

gcloud iam roles update editor --project $DEVSHELL_PROJECT_ID --file new-role-definition.yaml

In your above command, look out for problems with the content of new-role-definition.yaml

Solution 2:[2]

Please empty your etag in the new-role-definition.yaml and change the [PROJECT_ID] to your id(qwiklabs-gcp-01-7bc9f94ad9bd)and update it using the command gcloud iam roles update editor --project $DEVSHELL_PROJECT_ID --file new-role-definition.yaml in your cloudshell

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Narendra
Solution 2 Vishnuraj Saravanan