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

Urand compile fails on Windows #1

Closed
rustomax opened this issue Jan 7, 2021 · 3 comments
Closed

Urand compile fails on Windows #1

rustomax opened this issue Jan 7, 2021 · 3 comments

Comments

@rustomax
Copy link
Owner

rustomax commented Jan 7, 2021

$ nimble install npg
Downloading https://github.com/rustomax/npg using git
Verifying dependencies for npg@0.1.0
Installing passgen@>= 0.1.0
Downloading https://github.com/rustomax/nim-passgen using git
Verifying dependencies for passgen@0.1.0
Installing urand@>= 0.1.0
Downloading https://github.com/Matceporial/nim-urand using git
Verifying dependencies for urand@0.1.0
Installing urand@0.1.0
Success: urand installed successfully.
Installing passgen@0.1.0
Success: passgen installed successfully.
Installing npg@0.1.0
Building npg/npg.exe using c backend
.nimble\pkgs\urand-0.1.0\urand.nim(61, 29) Error: initialization not allowed here
Prompt: Build failed for 'npg@0.1.0', would you like to try installing 'npg@#head' (latest unstable)? [y/N]
Answer: y
Downloading https://github.com/rustomax/npg using git
Verifying dependencies for npg@#head
Info: Dependency on passgen@>= 0.1.0 already satisfied
Verifying dependencies for passgen@0.1.0
Info: Dependency on urand@>= 0.1.0 already satisfied
Verifying dependencies for urand@0.1.0
Installing npg@#head
Building npg/npg.exe using c backend
.nimble\pkgs\urand-0.1.0\urand.nim(61, 29) Error: initialization not allowed here
Tip: 26 messages have been suppressed, use --verbose to show them.
Error: Build failed for package: npg
... Execution failed with exit code 1
... Command: .nimble\bin\nim.exe c --colors:on --noNimblePath -d:release -d:NimblePkgVersion=0.1.0 --path:.nimble\pkgs\passgen-0.1.0 --path:.nimble\pkgs\urand-0.1.0 --hints:off -o:AppData\Local\Temp\nimble_17884\githubcom_rustomaxnpg_#head\npg.exe AppData\Local\Temp\nimble_17884\githubcom_rustomaxnpg_#head\src\npg.nim

@ringabout
Copy link

may be related
icyphox/nanoid.nim#1

It seems that the issue is caused by CryptGenRandom being deprecated: https://docs.microsoft.com/en-us/windows/desktop/api/wincrypt/nf-wincrypt-cryptgenrandom. It must be missing in my Windows 10 Insider build.
nim-random uses it for urandom on Windows: https://github.com/oprypin/nim-random#randomurandom
Why can't we switch to the random module from stdlib?

Now you can try std/sysrand, though it is on devel and expermental.
nim-lang/Nim#16459

@rustomax
Copy link
Owner Author

@xflywind correct, I didn't want use random from stdlib because of known quality issues. See for instance, https://forum.nim-lang.org/t/6843#42756. I'll look into what's available when I get the chance. Thanks for the pointer to std/sysrand.

@rustomax
Copy link
Owner Author

Did a major rework of nim-passgen library that NPG is based on to use nimcrypto random number generator. This enabled a much wider platform support, including Windows, Linux, MacOS and some versions of BSD.

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

No branches or pull requests

2 participants