crystal-lang / shards

Dependency manager for the Crystal language
Other
766 stars 102 forks source link

Override for `development_dependencies` #655

Open jwoertink opened 2 weeks ago

jwoertink commented 2 weeks ago

I'm trying to test an update locally on Windows, and I'm not able to use the shard override for development_dependencies.

# shard.yml
name: test
version: 0.1.0
crystal: '>= 1.14.0'
license: MIT
development_dependencies:
  db:
    github: crystal-lang/crystal-db
    version: 0.13.1
# shard.override.yml
development_dependencies:
  db:
    github: crystal-lang/crystal-db
    branch: master
> $env:SHARDS_OVERRIDE = 'shard.override.yml'
> shards install

However, I do see that overrides from dependencies make it over. It seems to be just the development_dependencies that are ignored.

Expected Output

The install output should say "Installing db (0.13.1 at 892c256)" Checking inside of the lib\db\src I expected to see changes made since the 0.13.1 release.

Actual Output

The install output says "Installing db (0.13.1)" and the lib dir shows code from 3eaac85

straight-shoota commented 2 weeks ago

This is not specific to Windows. The same thing happens on Linux.

It looks like overrides only apply to dependencies, not to development_dependencies:

https://github.com/crystal-lang/shards/blob/9a5e5b627410573b759bd92871e6850bcb7bd54a/src/molinillo_solver.cr#L46

I'm not sure if this is completely intentional or just an omission. The documentation only mentions that the override file provides overrides for dependencies (https://github.com/crystal-lang/shards/blob/master/docs/shards.adoc#files), although the language is a bit fuzzy because both dependencies and development_dependencies are categories of dependencies.

Btw. you don't need to set $env:SHARDS_OVERRIDE = 'shard.override.yml'. That's already the default value.

ysbaddaden commented 2 weeks ago

I don't see any issues that dependencies wouldn't have, so I guess it was just an omission.

straight-shoota commented 2 weeks ago

I suppose a possible explanation is that shards does not install nested development_dependencies, only those defined in the top shard.yml. So it's considerably more straightforward to override them there directly, compared to overriding nested dependencies' shard.yml.

Having to edit shard.yml directly is still not convenient for keeping a local override outside of git and consistent across branches etc. So I guess it makes sense to add overrides for development_dependencies as well.