Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

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

Closed
plietar opened this issue Jul 15, 2017 · 3 comments
Closed

Comments

@plietar
Copy link
Contributor

plietar commented Jul 15, 2017

/> 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
Copy link

CandleCandle commented Dec 5, 2017

/> 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;

  • Convert paths to their absolute form and storing that, thus rendering the bundle.json useless to commit into VCS (as noone else will be able to use it)
  • Convert any relative path to an absolute path just before calling git.
  • Work out the correct number of ../ elements to add to the git command which is likely to be two, as dependencies are stored two deep.

@SeanTAllen
Copy link
Member

Not item 1.

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

@SeanTAllen SeanTAllen changed the title Local dependencies are relative to invocation, not bundle.json Local dependencies, when added via add, are relative to invocation directory, not bundle.json Jul 12, 2018
@SeanTAllen SeanTAllen changed the title Local dependencies, when added via add, are relative to invocation directory, not bundle.json Local dependencies are relative to invocation directory, not bundle.json Jul 12, 2018
@rawkode
Copy link
Member

rawkode commented Jul 24, 2018

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

rawkode pushed a commit to rawkode/pony-stable that referenced this issue Jul 24, 2018
rawkode pushed a commit to rawkode/pony-stable that referenced this issue Jul 25, 2018
rawkode pushed a commit to rawkode/pony-stable that referenced this issue Jul 25, 2018
SeanTAllen pushed a commit that referenced this issue Aug 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants