Skip to content

System check script issues on Windows #910

@jwoertink

Description

@jwoertink

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    WindowsAny task that is specific to making Lucky work on Windows.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions