crystal-lang/shards

Dependencies are satisfied rarely works

faustinoaq opened this issue · 11 comments

Hi @ysbaddaden @RX14

Always I execute shards build to build my crystal projects and it works very well, However shards is fetching my depencencies everytime I execute it, first time is slower because is cloning repositories, next times are a bit faster but still take some time.

I'm wondering why it doesn't show something like:

➜ shards build project
Dependencies are satisfied
Building: project

Almost always I see:

➜ project shards build project
Fetching https://github.com/amberframework/amber.git
Fetching https://github.com/luislavena/radix.git
Fetching https://github.com/jeromegn/kilt.git
Fetching https://github.com/jeromegn/slang.git
Fetching https://github.com/stefanwille/crystal-redis.git
Fetching https://github.com/mosop/cli.git
Fetching https://github.com/mosop/optarg.git
Fetching https://github.com/mosop/callback.git
Fetching https://github.com/mosop/string_inflection.git
Fetching https://github.com/mosop/teeplate.git
Fetching https://github.com/samueleaton/sentry.git
Fetching https://github.com/juanedi/micrate.git
Fetching https://github.com/crystal-lang/crystal-db.git
Fetching https://github.com/jwaldrip/shell-table.cr.git
Fetching https://github.com/askn/spinner.git
Fetching https://github.com/will/crystal-pg.git
Fetching https://github.com/crystal-lang/crystal-mysql.git
Fetching https://github.com/crystal-lang/crystal-sqlite3.git
Fetching https://github.com/amberframework/granite-orm.git
Fetching https://github.com/amberframework/quartz-mailer.git
Fetching https://github.com/raydf/smtp.cr.git
Fetching https://github.com/amberframework/jasper-helpers.git
Fetching https://github.com/amberframework/garnet-spec.git
Fetching https://github.com/ysbaddaden/selenium-webdriver-crystal.git
Using amber (0.3.6)
Using radix (0.3.8)
Using kilt (0.4.0)
Using slang (1.7.0)
Using redis (1.9.0)
Using cli (0.6.10)
Using optarg (0.5.8)
Using callback (0.6.3)
Using string_inflection (0.2.1)
Using teeplate (0.4.5)
Using sentry (0.1.1)
Using micrate (0.3.0)
Using db (0.4.3)
Using shell-table (0.9.2)
Using spinner (0.1.1)
Using pg (0.13.4)
Using mysql (0.3.3)
Using sqlite3 (0.8.3)
Using granite_orm (0.7.8)
Installing quartz_mailer (0.2.0 at 0.2.1)
Installing smtp (0.1.0 at 0.1)
Using jasper_helpers (0.1.6)
Using garnet_spec (0.1.1)
Using selenium (0.3.0)
Building: project

Even if my shards are already satisfied

Versions:

➜  project shards --version
Shards 0.7.2 (2017-11-23)
➜  project crystal --version
Crystal 0.23.1 (2017-09-10) LLVM 5.0.0

Just some crystal projects works as I expected showing Dependencies are satisfied 👍

ok

But almost every project I build keep fetching shards every time 😞

fail

What if you run "shards install" initially then run "shards build"?

The same happens, keep fetching during shards build even after shards install

fetching

But I'm wondering Why 👇 works?

ezgif-4-91d28b935d

  • Maybe because is a small project?
  • Maybe because dependencies doesn't have a version or tag?

I can reproduce this with ambrockets. These two lines from the build command are interesting:

Installing quartz_mailer (0.2.0 at 0.2.1)
Installing smtp (0.1.0 at 0.1)

These are exactly the same versions as had been installed in the previous run of shards install, so it seems like shards does not recognize it already has the correct versions and tries to reinstall.
Perhaps it has something to do with the reported/installed version not exactly matching the version in the spec?

The issue is in the "shards check" command. It fails, and causes the install command to run. I believe @straight-shoota is right. Something confuses shards, and it doesn't understand a version has been correctly installed.

I found the issue 🎉

The problem is v0.1 version on:

  smtp:
    github: raydf/smtp.cr
    version: ~> 0.1

I did a fork updating smtp shard to:

  smtp:
    github: faustinoaq/smtp.cr
    version: ~> 0.2.0

Then shards build works again 💯

➜ shards build ambrockets
Fetching https://github.com/faustinoaq/amber.git
Fetching https://github.com/luislavena/radix.git
Fetching https://github.com/jeromegn/kilt.git
Fetching https://github.com/jeromegn/slang.git
Fetching https://github.com/stefanwille/crystal-redis.git
Fetching https://github.com/mosop/cli.git
Fetching https://github.com/mosop/optarg.git
Fetching https://github.com/mosop/callback.git
Fetching https://github.com/mosop/string_inflection.git
Fetching https://github.com/mosop/teeplate.git
Fetching https://github.com/samueleaton/sentry.git
Fetching https://github.com/juanedi/micrate.git
Fetching https://github.com/crystal-lang/crystal-db.git
Fetching https://github.com/jwaldrip/shell-table.cr.git
Fetching https://github.com/askn/spinner.git
Fetching https://github.com/will/crystal-pg.git
Fetching https://github.com/crystal-lang/crystal-mysql.git
Fetching https://github.com/crystal-lang/crystal-sqlite3.git
Fetching https://github.com/amberframework/granite-orm.git
Fetching https://github.com/faustinoaq/quartz-mailer.git
Fetching https://github.com/faustinoaq/smtp.cr.git
Fetching https://github.com/amberframework/jasper-helpers.git
Fetching https://github.com/amberframework/garnet-spec.git
Fetching https://github.com/ysbaddaden/selenium-webdriver-crystal.git
Installing amber (0.3.8)
Installing radix (0.3.8)
Installing kilt (0.4.0)
Installing slang (1.7.0)
Installing redis (1.9.0)
Installing cli (0.6.10)
Installing optarg (0.5.8)
Installing callback (0.6.3)
Installing string_inflection (0.2.1)
Installing teeplate (0.4.5)
Installing sentry (0.1.1)
Installing micrate (0.3.0)
Installing db (0.4.3)
Installing shell-table (0.9.2)
Installing spinner (0.1.1)
Installing pg (0.13.4)
Installing mysql (0.3.3)
Installing sqlite3 (0.8.3)
Installing granite_orm (0.7.8)
Installing quartz_mailer (0.2.4)
Installing smtp (0.2.0)
Installing jasper_helpers (0.1.6)
Installing garnet_spec (0.1.1)
Installing selenium (0.3.0)
Building: ambrockets
➜  ambrockets git:(master) ✗ shards build ambrockets
Dependencies are satisfied
Building: ambrockets
➜  ambrockets git:(master) ✗ shards build ambrockets
Dependencies are satisfied
Building: ambrockets
➜  ambrockets git:(master) ✗ shards build ambrockets
Dependencies are satisfied
Building: ambrockets

Now, I'm wondering, why shards is complaining about v0.1?

The issue is caused by a mismatch between the v1.0 tag and the version: 0.1.0 in shard.yml in the smtp shard.

This happens to work when resolving, because v0.1 matches the ~> 0.1.0 constraint, but the locked version will be 0.1 in shard.lock which doesn't equal 0.1.0, which in turn causes shards check to fail —once a lock file is present, version constraints do not apply, and installed versions must be exact.

We should always use versions from shard.yml, and only use the repository tags to identify/seek versions in the repository tree.

@ysbaddaden Thank you! I think I can close this issue now 👍

RX14 commented

This is still a bug/todo.

Not exactly a bug, since this is caused by mismatched version numbers (1.0 isn't 1.0.0), but we can smooth things out.