crystal-lang / shards

Dependency manager for the Crystal language
Other
764 stars 100 forks source link

git resolver error on windows with space in username #648

Open dsisnero opened 1 week ago

dsisnero commented 1 week ago

On my work computer my username has a space "Dominic E Sisneros" -( not by choice)

When trying to install crimson, I get an error because of this space in trying to build:

Resolving dependencies
Fetching https://github.com/naqvis/crystar.git
Fetching https://github.com/devnote-dev/cling.git
Fetching https://github.com/mamantoha/crest.git
Fetching https://github.com/mamantoha/http-client-digest_auth.git
Fetching https://github.com/mamantoha/http_proxy.git
Installing cling (3.0.0 at b833b59)
Installing http-client-digest_auth (0.6.0)
Installing http_proxy (0.12.0)
Installing crest (1.4.1)
Installing crystar (0.4.0)
Failed git --work-tree=C:\windows_home\src\crystal_repos\crimson\lib\crystar checkout refs/tags/v0.4.0 -- ..
basename: extra operand ‘Sisneros/AppData/Local/shards/cache/github.com/naqvis/crystar.git/./hooks/post-checkout’
Try 'basename --help' for more information.
C:/Users/Dominic E Sisneros/AppData/Local/shards/cache/github.com/naqvis/crystar.git/./hooks/post-checkout: line 17: C:/Users: Is a directory
Hook C:/Users failed with error code 126

Same error with shards install:

C:\windows_home\src\crystal_repos\crimson>shards install
Resolving dependencies
Fetching https://github.com/devnote-dev/cling.git
Fetching https://github.com/mamantoha/crest.git
Fetching https://github.com/naqvis/crystar.git
Fetching https://github.com/mamantoha/http-client-digest_auth.git
Fetching https://github.com/mamantoha/http_proxy.git
Using cling (3.0.0 at b833b59)
Using http-client-digest_auth (0.6.0)
Using http_proxy (0.12.0)
Using crest (1.4.1)
Installing crystar (0.4.0)
Failed git --work-tree=C:\windows_home\src\crystal_repos\crimson\lib\crystar checkout refs/tags/v0.4.0 -- ..
basename: extra operand ‘Sisneros/AppData/Local/shards/cache/github.com/naqvis/crystar.git/./hooks/post-checkout’
Try 'basename --help' for more information.
C:/Users/Dominic E Sisneros/AppData/Local/shards/cache/github.com/naqvis/crystar.git/./hooks/post-checkout: line 17: C:/Users: Is a directory
Hook C:/Users failed with error code 126
straight-shoota commented 1 week ago

According to the error message, the error is coming from the post-checkout hook in crystar.git. I don't think shards has anything to do with it directly. However, since the cached repo is managed by shards, it should usually not have any hooks defined whatsoever. Shards certainly does not initiate installing any hooks. So why is it there? My guess is the hook is installed automatically from git's template directory. Take a look at git config --get init.templateDir to see if the hook is defined there.

For a quick fix, you could simply remove C:/Users/Dominic E Sisneros/AppData/Local/shards/cache/github.com/naqvis/crystar.git/./hooks/post-checkout.

Having customized user configuration screw up shard's repo caching is not good. I think shards should probably prevent installing custom hooks. Or really any customization. It should just clone the upstream repo plainly without any modifications.