Issues with Crimson on Windows

Probably is an issue, i install Crystal use scoop which following the official guides, after i uninstall Crystal use scoop, but crimson still warn me crystal was not uninstalled.(check following screenshot)

image

And, then, install crystal use crimson failed too.

image

But it install sucessful if run only crimson install without version.

I try this on Win10 in VirtualBox, this is a relatively clean system, only install Crystal use scoop several times.

Thanks

1 Like

Crimson checks if crystal.exe is available in PATH so somewhere on your system it’s finding Crystal, not necessarily from Scoop.

I’ve found the cause of that strange exception and fixed it, I’ll publish a patch release shortly. Thanks for the report :+1:

You are right, I don’t know when I installed version 1.8.1, not use scoop, so scoop can not uninstall it.

After update to 1.0.1, i can install specified version now.

PS C:\Users\zw963> crimson list
1.14.0
1.13.2

But i can’t switch to installed version, maybe config issue? is there no need source a shell file as we do in Linux world?

PS C:\Users\zw963> crimson use 1.14.0
PS C:\Users\zw963> crystal version
Crystal 1.8.1 [a59a3db] (2023-04-20)

LLVM: 15.0.7
Default target: x86_64-pc-windows-msvc
PS C:\Users\zw963> crimson switch 1.14.0
PS C:\Users\zw963> crystal version
Crystal 1.8.1 [a59a3db] (2023-04-20)

LLVM: 15.0.7
Default target: x86_64-pc-windows-msvc
PS C:\Users\zw963>

That’s a system issue: it finds Crystal 1.8.1 before it reaches Crimson’s environment paths. Crimson wont remove existing Crystal versions on your system, it will only warn you about them.

I don’t know about CMD but with PowerShell you can do (Get-Command crystal).Source | Remove-Item then run crimson setup just to make sure everything is good.

Okay, get-command work, i find and delete Crystal 1.8.1.

but still not work. (command exists in PATH, but run it no op)

PS C:\Users\zw963> crimson.exe setup
Checking dependencies
Checking additional dependencies
No additional dependencies for this platform
PS C:\Users\zw963> crimson use 1.14.0
PS C:\Users\zw963> crystal version
PS C:\Users\zw963> crystal
PS C:\Users\zw963> Get-Command crystal

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     crystal.exe                                        1.14.0.0   C:\Users\zw963\AppData\Local\Programs\...


PS C:\Users\zw963> crystal version

I try remove 1.14.0 and install it again, but no luck.

PS C:\Users\zw963> crimson remove 1.14.0
PS C:\Users\zw963> crimson install 1.14.0
Fetching available versions...
Installing Crystal version: 1.14.0
Downloading sources...
Unpacking archive to destination...
1808 files unpacked (46.2MiB)
Cleaning up processes...
PS C:\Users\zw963> crimson use 1.14.0
PS C:\Users\zw963> crystal version

@Devonte , i checked those files in C\Users\zw963\AppData\Local\Programs\, but all files is zero bytes.

PS C:\Users\zw963\AppData\Local\Programs\Crystal> dir


    目录: C:\Users\zw963\AppData\Local\Programs\Crystal


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---l        2024/10/14     12:42              0 crystal.exe
-a---l        2024/10/14     12:42              0 crystal.pdb
-a---l        2024/10/15      1:55              0 gc.dll
-a---l        2024/10/15      1:55              0 iconv-2.dll
-a---l        2024/10/15      1:55              0 libcrypto-3-x64.dll
-a---l        2024/10/15      1:55              0 libffi.dll
-a---l        2024/10/15      1:55              0 libssl-3-x64.dll
-a---l        2024/10/15      1:55              0 libxml2.dll
-a---l        2024/10/15      1:55              0 LLVM-C.dll
-a---l        2024/10/15      1:55              0 mpir.dll
-a---l        2024/10/15      1:55              0 pcre.dll
-a---l        2024/10/15      1:55              0 pcre2-8.dll
-a---l        2024/10/14     12:42              0 shards.exe
-a---l        2024/10/15      1:55              0 yaml.dll
-a---l        2024/10/15      1:55              0 zlib1.dll

I am wrong, those file not zero bytes, it just not work when use 1.14.0, after i switch to 1.13.2, it works now.

PS C:\Users\zw963\AppData\Local\Programs\Crystal> crimson use 1.13.2
PS C:\Users\zw963\AppData\Local\Programs\Crystal> crystal version
Crystal 1.13.2 [879ec12]

LLVM: 18.1.1
Default target: x86_64-pc-windows-msvc

But 1.14.0 still not work.

I can’t reproduce this:


Have you tried restarting your terminal? I know that symlinks don’t always play well with CMD/PowerShell. If you have refreshenv installed I’d advise giving that a try too.

Not work, i try on CMD, get another new error (check screenshot). i rebooted my system before try it.

What does the message box say?

What does the message box say?

Sorry,

Application cannot be initialized normally (0xc0000142). Please click OK and close the application.

It may be a dependency issue for Crystal 1.14.0, because 1.13.2 work well, but what ever i install Crystal 1.14.0 use scoop or crimson, still get same issue.

ping @straight-shoota , how to find the reason for this issue?


EDIT:

I have no idea what happen, it’s seem like 1.13.2 not work too. I swear this is almost an unused Windows 10 system in VirtualBox, except for previously installing and configuring Scoop and Crystal, didn’t change nothing.

I even download official installer and reinstall it again, still not work.

1 Like

It might be an issue with missing dependencies about the vs_cpp_build_tools. You can download Crystal directly from Github, check if it works, and compare to confirm this.

I test on another fresh Installed Win11 24H2 professional version. get following error:


PS C:\Users\zw963> crimson setup
error: Unexpected exception:
error: Error creating symlink: ‘C:\Users\zw963\AppData\Roaming\crimson\bin\crystal.exe’ → ‘C:\Users\zw963\AppData\Local\Programs\Crystal\crystal.exe’: Client does not have necessary permissions.
error: Please report this on the Crimson GitHub issues:
error: Issues ¡ crimson-crystal/crimson ¡ GitHub


You can download Crystal directly from Github, check if it works, and compare to confirm this.

Same, i tried the windows installer and zip file, both of them not work.

It might be an issue with missing dependencies about the vs_cpp_build_tools

Version may not be new enough, but it works before, and my win10 never update it since then.

I faced a similar issue with Crimson earlier this year: Crystal was unable to find the DLLs (0xC0000135). Its for this reason that Crimson forces you to run crimson setup before you can do anything else. However, 0xc0000142 indicates it’s finding the DLLs but it can’t load them for whatever reason.

There was a library change between 1.13.3 and 1.14.0, Crystal is now using iconv-2.dll instead of libiconv.dll. You can check if Crimson has properly linked it by running dir %LOCALAPPDATA%\Programs\Crystal, you should see iconv-2.dll is symlinked to the absolute path in the Crimson path.

Next up would be checking that the executable is properly linked to the DLL. You can do this by:

  1. Opening the Visual Studio Developer Command Prompt (typing “developer” in the start menu should bring it up)
  2. Running dumpbin /dependents %APPDATA%\crimson\crystal\1.14.0\crystal.exe

Assuming that’s all correct, we’ll have to go a bit deeper. Press Windows + R, type eventvwr and enter. We shouldn’t need to navigate it just yet. Keep it running in the background and run crystal.exe in command prompt. That should give you a direct error message window.

Running dumpbin /dependents %APPDATA%\crimson\crystal\1.14.0\crystal.exe

That should give you a direct error message window.

Incorrect application name: crystal.exe, version: 0.0.0.0, timestamp: 0x67068da7
Error module name: MSVCP140.dll, version: 14.34.31931.0, timestamp: 0xd1597dcd
Exception code: 0xc0000005
Error offset: 0x000000013008
Error process ID: 0xc10
Error application startup time: 0x01db1f0c51ebb4fa
Wrong application path: C: \ Users \ zw963 \ scoop \ apps \ crystal \ current \ crystal.exe
Error module path: C: \ Windows \ SYS32 \ MSVCP140.dll
Report ID: c0a3918e-c43c-4407-bf79-c00f1951a502

I wonder if this is a knock-on effect from Add `src/SOURCE_DATE_EPOCH` to release tree by straight-shoota ¡ Pull Request #14574 ¡ crystal-lang/crystal ¡ GitHub (cc: @straight-shoota, @HertzDevil).

On a slightly unrelated note, I compared the properties between 1.13.3, 1.14.0 from Crimson and 1.14.0 from Scoop, I don’t know if there’s anything meaningful to deduce from this:

Before install 1.14.0 use crimson, the older version work well.

but, for now, after i do following process:

  1. scoop uninstall crimson
  2. scoop cleanup crimson
  3. scoop update
  4. scoop install crystal

the crystal still not work well on my Win10, but i test it on another new installed Win 11, 1.14.0 work well.