Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locally developed packages are not taken into account when resolving http dependencies #543

Closed
zah opened this issue Sep 15, 2018 · 7 comments

Comments

@zah
Copy link
Member

zah commented Sep 15, 2018

Consider the following scenario:

  1. You check out a project having a nimble file specifying some of its dependencies as a HTTP URLs.

  2. You want to fix an issue in one of the HTTP dependencies, so you clone the this package locally and you run nimble develop to make it available system-wide. You fix the issue and you delete any previously downloaded version from your ~/.nimble/pkgs folder.

  3. You run nimble test in the original repo, cloned in step 1. At this point, Nimble doesn't recognize your local copy of the dependent package and instead downloads a fresh copy from the specified HTTP URL. Your local fixes are ignored in favor of the downloaded unmodified copy.

Expected outcome:

Nimble should be able to recognize that a locally linked version of a package (with nimble develop) satisfies a HTTP dependency for the same package.

Possible solutions:

  1. The problem is that Nimble cannot figure out that a particular URL used as a dependency matches a locally installed package. One way to solve this is to introduce a local database for the installed packages which will keep a reverse "URL to package name" lookup table.

  2. Nimble can download the HTTP dependency in a temporary location, then it can inspect the downloaded package name and figure out that it's already present as a nimble develop link.

  3. The user may be required to specify the package name when introducing a HTTP dependency. The syntax may look like this:

requires "nim >= 0.18.1",
         "httputils@https://github.com/status-im/nim-http-utils >= 0.2.0"
         # here, `httputils` is the package name

The specified package name will allow Nimble to check for an existing installation of the package. A similar solution is used by other build tools such as Scala's SBT. Alternatively, we can introduce some new properly typed dependency-specification API:

uses("eth_p2p", git = "https://github.com/p2p", branch = "master")

I've pushed a very simple project demonstrating the issue here:

https://github.com/zah/nim-nimble-issue

To see the issue, you'll also need to clone the httputils package from https://github.com/status-im/nim-http-utils and then attempt to introduce changes in it after linking it with nimble develop.

zah added a commit to status-im/nim-eth-trie that referenced this issue Sep 15, 2018
zah added a commit to status-im/nim-json-rpc that referenced this issue Sep 15, 2018
zah added a commit to status-im/nim-eth-common that referenced this issue Sep 15, 2018
zah added a commit to status-im/nim-eth-p2p that referenced this issue Sep 15, 2018
zah added a commit to status-im/nimbus-eth1 that referenced this issue Sep 15, 2018
@dom96 dom96 added the Bug label Sep 15, 2018
@zah
Copy link
Member Author

zah commented Sep 18, 2018

@dom96, can you comment on which of the proposed solutions would be considered most acceptable?

@dom96
Copy link
Collaborator

dom96 commented Sep 18, 2018

I think the package name can be reverse looked up in the package list. It wouldn't be perfect but I don't particularly like any of the other solutions.

To be honest, I consider this as more of a user issue. Don't specify dependencies using URLs.

@zah
Copy link
Member Author

zah commented Sep 19, 2018

Using URLs is mandatory when your packages are not registered in the Nimble package list. This will be true for example if your packages are considered private. Also, every package starts as being private. During the initial most active development, most users are likely to experience the problems described here.

@brentp
Copy link

brentp commented Dec 13, 2018

IIUC, this is also useful if, for example one builds a package that depends on a fork of the canonical package. This is a situation that I'm currently encountering.

@zah
Copy link
Member Author

zah commented Dec 17, 2018

This issue can be solved by implementing a proper lock file (#127).

The lock file would include the resolved package name, the URL appearing in the nimble file and the revision hash/tag. The resolved package name would be enough for Nimble to look for a locally linked development version of the package.

When I create new commits in a locally linked library, the lock files of other projects that depend on it will be updated every time nimble test completes successfully. This will provide strong enough version pinning for libraries that haven't published tagged versions yet. It would be recommended to the users that lock files are stored in git.

@dom96
Copy link
Collaborator

dom96 commented Sep 21, 2019

Not high-pri as it will be fixed via lock file support.

@yyoncho
Copy link
Contributor

yyoncho commented Aug 30, 2022

I believe this one is already fixed (most likely when nimble.develop was introduced). I tested with the following steps:

  1. Created a package with dependency https://github.com/GULPF/timezones
  2. I did nimble develop timezones
  3. I did a change in the locally cloned copy and then created a test depending on this change.
  4. I deleted pkgs2 copy. I did nimble test and the test was still green.

I tested also with nimble develop --global and the results seem to be the same.

@zah zah closed this as completed Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants