devonfw / ide

Tool to automate setup and update of development environment (esp. for Java projects).
Apache License 2.0
35 stars 101 forks source link

yarn is not installing properly on MacOSX and Windows #1246

Closed jan-vcapgemini closed 1 year ago

jan-vcapgemini commented 1 year ago

Expected behavior

As a devonfw-ide Windows and MacOS user I want to install yarn, so that I can use it for my projects.

Actual behavior

devon yarn is not installed automatically (just with devon yarn setup)

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. Run devon yarn

Related/Dependent Issues

Comments/Hints:

Affected version:

hohwille commented 1 year ago

Please try to include logs, as I could not get what the actual problem was and could not reproduce the bug in the first place. So here is my log:

hohwille@CE49454 MSYS /d/projects/test2
$ devon yarn
Running: yarn install
/d/projects/test2/scripts/command/yarn: line 84: yarn: command not found
sed: can't read package.json: No such file or directory
No build script is present in package.json - skipping to run build script.

hohwille@CE49454 MSYS /d/projects/test2
$ devon yarn setup
Running: npm install -g yarn@latest

added 1 package in 1s

hohwille@CE49454 MSYS /d/projects/test2
$ devon yarn
Running: yarn install
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.05s.
sed: can't read package.json: No such file or directory
No build script is present in package.json - skipping to run build script.
hohwille commented 1 year ago

I am slightly confused why this is happening. If you call devon yarn with no argument, it will do this: https://github.com/devonfw/ide/blob/a66c6261fd7c144adedf264edbe97d96775b8bff/scripts/src/main/resources/scripts/command/yarn#L118

This is calling the following: https://github.com/devonfw/ide/blob/a66c6261fd7c144adedf264edbe97d96775b8bff/scripts/src/main/resources/scripts/command/yarn#L89

And that first calls this: https://github.com/devonfw/ide/blob/a66c6261fd7c144adedf264edbe97d96775b8bff/scripts/src/main/resources/scripts/command/yarn#L78

The actual bug seems to come from this condition: https://github.com/devonfw/ide/blob/a66c6261fd7c144adedf264edbe97d96775b8bff/scripts/src/main/resources/scripts/command/yarn#L34

Typically the silent argument should only suppress extra log output or extra verbose double checking of the installation. However, in the current yarn commandlet the installation is simply skipped if the silent argument is provided what is obviously a bug.