backstage / backstage

Backstage is an open platform for building developer portals
https://backstage.io
Apache License 2.0
26.47k stars 5.41k forks source link

🐛 Bug Report: Permissions Tutorial looking for plugins in a repo #20602

Closed bruno-watt-wcq closed 5 months ago

bruno-watt-wcq commented 6 months ago

📜 Description

wasted about 40 hours on this nightmare trying out each possible solution with no advancement.

Following the tutorial here fails right away on step 'Add these packages as dependencies for your Backstage app', as the command ignores the plugins that are stored locally and attempts to pull them from our repo.

So next step was to attempt publishing those demo plugins to our repo, then we get typescript transpile failures, complaining about imports and exports.

Is there some documentation that we can actually follow on how to use plugins?

👍 Expected behavior

allow me to demonstrate the permissions framework.

👎 Actual Behavior with Screenshots

error An unexpected error occurred: "https://XXXXXXXXXX/repository/npm-group/@internal%2fplugin-todo-list-backend: Not found". info If you think this is a bug, please open a bug report with the information provided in "/Users/xxxxxxxxx/playground/de-port/packages/backend/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. yarn add v1.22.19 [1/4] 🔍 Resolving packages... error An unexpected error occurred: "https://xxxxxx/repository/npm-group/@internal%2fplugin-todo-list: Not found". info If you think this is a bug, please open a bug report with the information provided in "/Users/xxxxxxx/playground/de-port/packages/app/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

👟 Reproduction steps

Follow the instructions listed above.

📃 Provide the context for the Bug.

No response

🖥️ Your Environment

No response

👀 Have you spent some time to check if this bug has been raised before?

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

No, I don't have time to work on this right now

vinzscam commented 6 months ago

Hi @bruno-watt-wcq, I'm sorry this has caused you some troubles. Have you executed step 1? If yes, then you shouldn't have any problem executing step 2. In step 2 we are not attempting to download any package, but just trying to reference them locally (as you've mentioned). I personally had some issues with yarn in the past, which had troubles locating packages in a monorepo. Could you try applying the changes manually?

packages/backend/package.json:

    "@backstage/plugin-search-backend-node": "...whathever",
    "@backstage/plugin-tech-insights-backend": "...whathever",
    "@backstage/plugin-techdocs-backend": "...whathever",
+   "@internal/plugin-todo-list-backend": "workspace:^",
+   "@internal/plugin-todo-list-common": "workspace:^",

and packages/app/package.json:

    "@backstage/plugin-user-settings": "^0.7.11-next.2",
    "@backstage/theme": "^0.4.3-next.0",
+   "@internal/plugin-todo-list": "workspace:^",
    "@material-ui/core": "^4.12.2",
    "@material-ui/icons": "^4.9.1",

once you've done, run yarn and see if it fixes the issue. These 👆 are basically the only changes that the two yarn add commands mentioned in step 2 are making.

bruno-watt-wcq commented 5 months ago

Hi,

Apologies for how long this took, I created this ticket on my client account not my personal one. I'll keep a closer monitor.

This hasn't actually made any change. I ran yarn install (and just yarn) and in both cases it says the following:

error Couldn't find package "@internal/plugin-entity-catalog-leaf@workspace:^" required by "app@0.0.0" on the "npm" registry.

We really dont want to publish the plugins, don't see what we are missing or how this should work.

bruno-watt-wcq commented 5 months ago

I may have kicked the can ever-so-slightly down the road.

after trying every combination under the sun adding the plugins manually to the app and backend package.json files like this enabled me to pull the internal modules into node_modules:

"@internal/plugin-entity-catalog-leaf": "file:../../plugins/entity-catalog-leaf",
"@internal/plugin-entity-catalog-leaf-common": "file:../../plugins/entity-catalog-leaf-common",

I can run yarn install and yarn tsc successfully. however when I run yarn build I see the following:

Error: Failed to compile './node_modules/@internal/plugin-entity-catalog-leaf/src/plugin.ts':
  Module parse failed: Unexpected token (20:52)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| } from '@internal/plugin-entity-catalog-leaf-common';
| 
> export const isEntityCatalogLeafAvailable = ( entity: Entity ) =>
|   Boolean( entity.metadata.annotations?.[CATALOG_LEAF_ANNOTATION]);
|

I suspect this has happened due to me essentially copying the structure of the linguist plugins from the master backstage repo.

I can see my plugins are being shifted into the correct node_modules/@internal folder but it looks like it's not doing any compilation. Is there some yarn/lerna config im missing somewhere?

bruno-watt-wcq commented 5 months ago

Sniffing about a little more I see that in the node_modules for my front end module (the error is surfacing in the front end module referencing the common module that both front and backend consume) the @internal/ module folder has copied across the the package but has not compiled it...feels like a (giant) hole in my Lerna/Yarn knowledge.

Joonpark13 commented 5 months ago

Hmm, sorry if I'm missing something obvious but what is the plugin-entity-catalog-leaf package? I don't believe it's one associated with the permission framework or the plugins written for its tutorial?

bruno-watt-wcq commented 5 months ago

That's the work we are working on now, the permissions tutorial was the closest to showing us how to make plugins work.

bruno-watt-wcq commented 5 months ago

Solved most of our issues with help from discord. closing out.

vj9486 commented 3 months ago

Hi ,

i am facing the same issue as @bruno-watt-wcq

error An unexpected error occurred: "https://xxxxxxxxxx/repository/npm-group/@internal%2fplugin-todo-list-backend: Not found". info If you think this is a bug, please open a bug report with the information provided in "/Users/xxxxxxxxx/playground/de-port/packages/backend/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. yarn add v1.22.19 [1/4] 🔍 Resolving packages... error An unexpected error occurred: "https://xxxxxx/repository/npm-group/@internal%2fplugin-todo-list: Not found". info If you think this is a bug, please open a bug report with the information provided in "/Users/xxxxxxx/playground/de-port/packages/app/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

i have tried this part also,

packages/backend/package.json:

+   "@internal/plugin-todo-list-backend": "workspace:^",
+   "@internal/plugin-todo-list-common": "workspace:^",

and packages/app/package.json:

+   "@internal/plugin-todo-list": "workspace:^",

after this i am facing this issue

error Couldn't find package "@internal/plugin-todo-list@workspace:^" required by "app@0.0.0" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Couldn't find package "@internal/plugin-todo-list-common@workspace:^" required by "backend@0.0.0" on the "npm" registry.
    at MessageError.ExtendableBuiltin (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:721:66)
    at new MessageError (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:750:123)
    at PackageRequest.<anonymous> (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:36590:17)
    at Generator.throw (<anonymous>)
    at step (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:310:30)
    at /usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:323:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: Couldn't find package "@internal/plugin-todo-list@workspace:^" required by "app@link:packages/app" on the "npm" registry.
    at MessageError.ExtendableBuiltin (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:721:66)
    at new MessageError (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:750:123)
    at PackageRequest.<anonymous> (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:36590:17)
    at Generator.throw (<anonymous>)
    at step (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:310:30)
    at /usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:323:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: Couldn't find package "@internal/plugin-todo-list-backend@workspace:^" required by "backend@0.0.0" on the "npm" registry.
    at MessageError.ExtendableBuiltin (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:721:66)
    at new MessageError (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:750:123)
    at PackageRequest.<anonymous> (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:36590:17)
    at Generator.throw (<anonymous>)
    at step (/usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:310:30)
    at /usr/local/lib/nodejs/node-v18.14.0-linux-x64/lib/node_modules/yarn/lib/cli.js:323:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

now i am not able to do yarn install also ,
can anyone help here, i am trying this for half a day Is there any correct documention to resolve this?

jedjebari commented 1 week ago

Hi I'm stuck with the same error 😕 It seems to be linked to https://github.com/yarnpkg/yarn/issues/4878

Workaround: add explicit versions for packages ; at this time of speaking : yarn --cwd packages/backend add @internal/plugin-todo-list-backend@1.0.27-next.0 @internal/plugin-todo-list-common@1.0.18

jedjebari commented 1 week ago

I'm using yarn in version 1.22.19