In a generated app, you get a script/system_check.cr which helps to ensure your app is setup and bootstrapped properly in development before booting. (e.g. if you need yarn to run your app, then ensure yarn is installed before trying to boot the app).
However, speaking of yarn, there's an issue on Windows.
The system_check runs this
|
if command_not_found "yarn" |
|
print_error "Yarn is not installed\n See https://yarnpkg.com/lang/en/docs/install/ for install instructions." |
|
end |
which checks for the existence of an executable yarn.
|
def command_not_found(command : String) : Bool |
|
Process.find_executable(command).nil? |
|
end |
This find_executable method will automatically append .exe to whatever command you pass in
https://github.com/crystal-lang/crystal/blob/bcff68af7e503648edcdfdea9ae6be1fa09b7c6b/src/process/executable_path.cr#L70-L79
This means it's actually looking for yarn.exe which doesn't exist. When you install node and yarn, yarn (as well as some other node related commands like pnpm, etc...) are just shell scripts. Even if yarn is installed properly, this will fail.
An alternate way to solve this could be to just run yarn -v and then check $?. That value seems to return 0 on Linux and True on Windows. I'd assume Process.run("yarn -v").normal_exit? would work, but it does feel a little hacky. I'm open to other ideas if anyone has any.
In a generated app, you get a
script/system_check.crwhich helps to ensure your app is setup and bootstrapped properly in development before booting. (e.g. if you need yarn to run your app, then ensure yarn is installed before trying to boot the app).However, speaking of
yarn, there's an issue on Windows.The system_check runs this
lucky_cli/src/web_app_skeleton/script/system_check.cr.ecr
Lines 14 to 16 in 0d67c0a
which checks for the existence of an executable
yarn.lucky_cli/src/web_app_skeleton/script/helpers/function_helpers.cr.ecr
Lines 20 to 22 in 0d67c0a
This
find_executablemethod will automatically append.exeto whatever command you pass inhttps://github.com/crystal-lang/crystal/blob/bcff68af7e503648edcdfdea9ae6be1fa09b7c6b/src/process/executable_path.cr#L70-L79
This means it's actually looking for
yarn.exewhich doesn't exist. When you install node and yarn, yarn (as well as some other node related commands like pnpm, etc...) are just shell scripts. Even if yarn is installed properly, this will fail.An alternate way to solve this could be to just run
yarn -vand then check$?. That value seems to return0on Linux andTrueon Windows. I'd assumeProcess.run("yarn -v").normal_exit?would work, but it does feel a little hacky. I'm open to other ideas if anyone has any.