winglang / wing

A programming language for the cloud โ˜๏ธ A unified programming model, combining infrastructure and runtime code into one language โšก
https://winglang.io
Other
5k stars 196 forks source link

Cant find @winglang/jsii-docgen while trying to build wingsdk #1019

Closed msalman-abid closed 1 year ago

msalman-abid commented 1 year ago

Hi, First-time contributor here - wanted to start work on a newbie issue for wingsdk, but unable to go through the build process. Trying to install dependencies through npm is throwing a 404 error (pretty sure due to the restricted @winglang package). Contributor's handbook isn't very clear how to resolve this hurdle, please advise.

Community Note

Please vote by adding a ๐Ÿ‘ reaction to the issue to help us prioritize. If you are interested to work on this issue, please leave a comment.

I tried this:

Tried installing dependencies using npm i , in both windows and ubuntu(WSL) to verify it isn't platform specific.

I expected this:

npm should be able to resolve (and install) all dependencies to build the wing sdk.

Instead, this happened:

Faced the following error:

npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@winglang%2fjsii-docgen - Not found npm ERR! 404 npm ERR! 404 '@winglang/jsii-docgen@^7.0.159' is not in this registry.

Component:

SDK, Contributor Experience

Wing Version:

No response

Node.js Version:

v18.12.1

Platform(s):

Linux, Windows

Anything else?

No response

Chriscbr commented 1 year ago

Thanks @msalman-abid for reporting this ๐Ÿ™ - I think this is a recent regression caused by some changes to our GitHub repositories. Right now this package is in a separate repository but it needs to be merged into our monorepo. I'll work on fixing this

monadabot commented 1 year ago

Congrats! :rocket: This was released in Wing 0.4.52.

Chriscbr commented 1 year ago

Hey @msalman-abid - can you try installing the dependencies and building the project to see if it works now?

msalman-abid commented 1 year ago

@Chriscbr I'm still facing this error: Error: Command failed: npm install npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@winglang%2fjsii-docgen - Not found npm ERR! 404 npm ERR! 404 '@winglang/jsii-docgen@*' is not in this registry. npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url.

Is this perhaps due to the dependencies @winglang/jsii-docgen & @winglang/wing-api-checker in the package.json file? Since these are protected packages, npm cant resolve these and therefore the build still fails

EDIT: formatting

Chriscbr commented 1 year ago

@msalman-abid Have you updated your branch to be synced with the latest commits to main? (you should see an apps/jsii-docgen directory in the code now)

msalman-abid commented 1 year ago

@Chriscbr I was (incorrectly) trying to run npm i before the build command this time, which resulted in this error. Perhaps running npm i is not advised?

For the scope of this issue, I've been able to build both @winglang/jsii-docgen and @winglang/wing-api-checker by navigating to their respective app folders. However, the build for the sdk still fails at this: ๐Ÿ‘พ build ยป post-compile ยป api-check | wing-api-check /bin/sh: 1: wing-api-check: Permission denied I'm not sure if this is an environment issue or something that I need to address, so I'm still trying to resolve this.

Chriscbr commented 1 year ago

Ok I'm able to reproduce your issue (the original permission error) - investigating

msalman-abid commented 1 year ago

Okay so one more update, I managed to move past the /bin/sh: 1: wing-api-check: Permission denied error by modifying the .projenrc.ts file. I changed line 41 @winglang/wing-api-checker@file:../../apps/wing-api-checker to "@winglang/wing-api-checker@file:../../apps/wing-api-checker/bin/wing-api-check". I changed it to point to the file in bin/ because of the prefix file before the path, which I took as a hint that it should be pointing to a file and not the entire directory.

Please advise on this fix, as I've now moved on to a new error : TSError: โจฏ Unable to compile TypeScript: .projenrc.ts:1:43 - error TS2307: Cannot find module 'projen' or its corresponding type declarations. This has the same permission 401 issue as the original npm i, as I cannot perform npm i projen. Given my unfamiliarity with projen, I am not sure if this is a step forwards or backwards.

msalman-abid commented 1 year ago

Update 2: Please ignore earlier attempt at fix. Resolved the /bin/sh: 1: wing-api-check: Permission denied by replacing the value for @winglang/jsii-docgen in package.json with the file:.. path with help from #1044.

Facing a new error (which is also reproducible by running npm run docgen):

๐Ÿ‘พ docgen | jsii-docgen -o API.md -l wing
/bin/sh: 1: jsii-docgen: Permission denied
๐Ÿ‘พ Task "docgen" failed when executing "jsii-docgen -o API.md -l wing" ...

If I need to build specific apps other than jsii-docgen and wing-api-checker or follow a different build process, please let me know

Chriscbr commented 1 year ago

@msalman-abid Yeah you've got the core of it, there's some issues dependencies not being linked properly. There's a small catch-22 because to apply the changes in the projen file, projen has to be installed, but you are unable to install dependencies. (It's possible to unstuck from this situation by fixing package.json directly, running npm install, and then update the projen file, but anyways, this might need some cleaning up...)

I've got a PR open that I think should fix this. Can you try checking it my branch (rybickic/local-imports) and running a clean install from the root of the project to see if it works now? You might need to clean everything out in the repo (git clean -fdx) to get it to work. I tried building from the branch on a gitpod (gitpod.io/#https://github.com/winglang/wing/tree/rybickic/local-imports) and I was able to get the dependencies installed alright.

msalman-abid commented 1 year ago

@Chriscbr gitpod build has the following error (stitched together relevant statements):

 FAIL  test/docgen/view/documentation.test.ts (69.804 s)
.
.
 โ— wing โ€บ single package

           thrown: "Exceeded timeout of 30000 ms for a test.
           Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

             4 |
             5 | describe("wing", () => {
           > 6 |   test("single package", async () => {
               |   ^
             7 |     const docs = await Documentation.forPackage("@aws-cdk/aws-ecr@1.106.0");
             8 |     try {
             9 |       const json = await docs.toJson({ language: Language.WING });

             at test/docgen/view/documentation.test.ts:6:3
             at Object.<anonymous> (test/docgen/view/documentation.test.ts:5:1)

 >  NX   Ran target build for 6 projects and 5 task(s) they depend on (3m)

    โœ”    6/7 succeeded [0 read from cache]

    โœ–    1/7 targets failed, including the following:
         - nx run jsii-docgen:build

I'll test on my local machine and get back to you soon

EDIT: looks like a gitpod env issue. A re-run for build resolved this. I'll update with test on local

Chriscbr commented 1 year ago

Got it -- yes, we can tweak those so it's less penalizing. (I think the only reason these kinds of timeouts are in place are to protect if some test hangs or loops forever)

monadabot commented 1 year ago

Congrats! :rocket: This was released in Wing 0.4.54.

msalman-abid commented 1 year ago

@Chriscbr quick update: the latest release also successfully builds on my local instance. Thanks for your support!

staycoolcall911 commented 1 year ago

Thank you for letting us know, @msalman-abid !