crystal-lang / shards

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

`--local` flag doesn't respect CRYSTAL_PATH #584

Closed CyberTailor closed 1 year ago

CyberTailor commented 1 year ago

Steps to reproduce

  1. Install dependencies to /tmp/crystalpath
  2. Add /tmp/crystalpath to the CRYSTAL_PATH environment variable
  3. Remove shards cache
  4. Run: shards --local build

Expected behavior

Dependencies are satisfied

Actual behavior

Resolving dependencies
Missing repository cache for "crystal-pg". Please run without --local to fetch it.
straight-shoota commented 1 year ago

The --local flag affects the repository cache, not the lib directory where dependencies are checked out. I figure the documentation for this option should be improved to make that clear.

If you want to have dependencies installed in a custom path, you can set the environment variable SHARDS_INSTALL_PATH.

However, if you simply want to use dependencies already installed in that path and not do any dependency resolution, there's no point in using shards at all. It has nothing to do. After adding that path to CRYSTAL_PATH you can just run crystal build directly.

CyberTailor commented 1 year ago

If you want to have dependencies installed in a custom path, you can set the environment variable SHARDS_INSTALL_PATH.

Same error.

After adding that path to CRYSTAL_PATH you can just run crystal build directly.

With shards build I don't have to write targets manually ;-)

straight-shoota commented 1 year ago

Same error.

Yes. --local tells shards to not update the repository cache. But it needs all dependency repositories to be available in the cache. When dependencies are missing, it asks to run without --local to be able to fetch them. Without a populated repository cache, shards cannot work.

Shards' job is to resolve dependencies. Your use case seems to have no need for that, so you should better do without trying to mess with shards to prevent it from its job.

If you want build recipes, I'd recommend to use a build system like make.