crystal-lang / shards

Dependency manager for the Crystal language
Other
758 stars 99 forks source link

"Error creating symlink" as a result of dependency project that has lib folder #598

Closed ExpliuM closed 6 months ago

ExpliuM commented 8 months ago

Terminal output

Resolving dependencies
Fetching https://github.com/project-osrm/osrm-backend.git
Shard "osrm-backend" version (5.24.0) doesn't have a shard.yml file
Installing osrm-backend (5.24.0)
Unhandled exception: Error creating symlink: '..' -> '/home/V09118B/projects/osrm_backend/lib/osrm-backend/lib': File exists (File::AlreadyExistsError)
  from /crystal/src/crystal/system/unix/file.cr:109:11 in 'install'
  from /shards/src/commands/install.cr:72:11 in 'run'
  from /shards/src/cli.cr:100:9 in '->'
  from /crystal/src/primitives.cr:266:3 in 'parse'
  from /shards/src/cli.cr:145:3 in '__crystal_main'
  from /crystal/src/crystal/main.cr:110:5 in 'main'
  from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'

shard.yml:

name: osrm-backend
version: 0.1.0
crystal: 1.0.0

repository: https://github.com/Project-OSRM/osrm-backend

dependencies:
  osrm-backend:
    github: Project-OSRM/osrm-backend
    version: ~> 5.24.0
straight-shoota commented 8 months ago

In general, shard repositories are not expected to have a lib folder because that would be overriden when installing dependencies for that shard.

However, I see you're using a repo that is not actually a shard (it has no shard.yml). I'm actually a bit surprised that it still works as a dependency, never considered that use case. But I suppose it's fine 🤷

The lib symlink is mostly for convenience when using the installed dependency as entry point and it allows it do discover its dependencies. So the symlink is not critical. I think shards can just skip it if lib already exists.