Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in Windows with Yarn from chocolatey #792

Closed
JD557 opened this issue Sep 5, 2023 · 2 comments · Fixed by #803
Closed

Doesn't work in Windows with Yarn from chocolatey #792

JD557 opened this issue Sep 5, 2023 · 2 comments · Fixed by #803

Comments

@JD557
Copy link
Contributor

JD557 commented Sep 5, 2023

So, chocolatey seems to install yarn on C:\Program Files (x86)\Yarn\bin, which contains the following files:

PS C:\Program Files (x86)\Yarn\bin> ls

    Directory: C:\Program Files (x86)\Yarn\bin

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          10/05/2022    11:40           1025 yarn
-a---          10/05/2022    11:40             34 yarn.cmd
-a---          10/05/2022    11:40           1015 yarn.js
-a---          10/05/2022    11:40             42 yarnpkg
-a---          10/05/2022    11:40             30 yarnpkg.cmd

yarn.cmd contains a windows launcher while yarn contains a Unix launcher.

So, running scala.sys.process.Process("yarn").! does not work, it should be scala.sys.process.Process("yarn.cmd").!

scala> scala.sys.process.Process("yarn").!
java.io.IOException: Cannot run program "yarn": CreateProcess error=2, The system cannot find the file specified
  at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1140)
  at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1074)
  at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:85)
  at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:117)
  at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang(ProcessBuilderImpl.scala:144)
  ... 37 elided
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
  at java.base/java.lang.ProcessImpl.create(Native Method)
  at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:500)
  at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
  at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1111)
  ... 41 more

scala> scala.sys.process.Process("yarn.cmd").!
yarn install v1.22.19
info No lockfile found.
$ :; (node ./preinstall.js > /dev/null 2>&1 || true)
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
error Could not write file "C:\\Program Files (x86)\\Yarn\\yarn-error.log": "EPERM: operation not permitted, open 'C:\\Program Files (x86)\\Yarn\\yarn-error.log'"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error An unexpected error occurred: "EPERM: operation not permitted, mkdir 'C:\\Program Files (x86)\\Yarn\\node_modules'".
val res1: Int = 1

As such docusaurusCreateSite is failing in

Process(List("yarn", "install"), cwd = website.value).execute()
Process(List("yarn", "run", "build"), cwd = website.value).execute()

@tgodzik
Copy link
Contributor

tgodzik commented Sep 22, 2023

Thanks for reporting! Would you be able to take a look at it maybe and see if there is a way to work around it?

Would it just be the case of checking if we are on windows and running yarn.cmd in those cases? Or should we do it only as a fallback?

@JD557
Copy link
Contributor Author

JD557 commented Sep 23, 2023

I'll try to check next week once I'm back at my normal machine.

I think it should be enough to call yarn.cmd on windows, but I want to double check that other install methods (e.g. via npm) also need that.

A fallback would probably also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants