ponylang / pony-stable

:horse: A simple dependency manager for the Pony language.
BSD 2-Clause "Simplified" License
134 stars 18 forks source link

Local dependencies are relative to invocation directory, not `bundle.json` #22

Closed plietar closed 6 years ago

plietar commented 7 years ago
/> tree
.
├── pony-bar
│   ├── bar
│   │   └── bar.pony
│   └── bundle.json
└── pony-foo
    └── foo
        └── foo.pony
/> cd pony-bar
/pony-bar> stable add local ../pony-foo
/pony-bar> cd bar
/pony-bar/bar> stable env ponyc -d
Building builtin -> /usr/local/Cellar/ponyc/0.15.0/packages/builtin
Building . -> /pony-bar/bar
Error:
foo: couldn't locate this path
Error:
/pony-bar/bar/bar.pony:1:1: can't load package 'foo'
use "foo"
^

Because I'm in the /pony-bar/bar folder, the ../pony-foo path refers to /pony-bar/pony-foo, which obviously doesn't exist. This seems unintuitive to me. I would expect all paths to be relative to the bundle.json file.

This probably affects local-git dependencies as well.

CandleCandle commented 6 years ago
/> tree
.
├── pony-bar
│   ├── bar
│   │   └── bar.pony
│   └── bundle.json
└── pony-foo
    └── foo
        └── foo.pony

/> cd pony-bar
/pony-bar> stable add local-git ../pony-foo
...
/pony-bar> stable fetch
fatal: '../pony-foo' does not appear to be a git repository

The bundle.json then contains the local-path of ../pony-foo

The command being run is git -C .deps/-pony-foo12345 pull ../pony-foo This executes git as if it was in the pony-bar/.deps/-pony-foo12345 directory, where ../pony-foo is highly likely to not exist.

The command that should be run, if using relative paths, is git -C .deps/-pony-foo12345 pull ../../../pony-foo

The work-around is to use an absolute path in the bundle.json.

With local repos (local-git and local) I see three options;

SeanTAllen commented 6 years ago

Not item 1.

I don't really see a difference between 2 and 3. It seems like the same thing, slightly different implementation.

rawkode commented 6 years ago

local-git actually uses the bundle's path:

  fun root_path(): String =>
    Path.join(bundle.path.path, Path.join(".deps", package_name))

I can make a similar change for local