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

Change semantics of optional dependencies #361

Closed
s-ludwig opened this issue Jun 27, 2014 · 2 comments
Closed

Change semantics of optional dependencies #361

s-ludwig opened this issue Jun 27, 2014 · 2 comments
Milestone

Comments

@s-ludwig
Copy link
Member

Currently, an optional dependency is satisfied once it is available locally. This doesn't allow the user to decide when to use an optional dependency on a per project basis, but rather will always be a per machine decision. The proposed new semantics are to satisfy an optional dependency iff:

  • another package in the dependency graph has a non-optional dependency to the same package
  • the optional package is explicitly listed in the dub.selections.json file

For the second option, there will also need to be a way to achieve this using the CLI, maybe simply by doing an explicit dub upgrade <name of optional dependency> within the project directory.

@s-ludwig s-ludwig added this to the 1.0.0 milestone Jun 27, 2014
@luismarques
Copy link

Ah, this was driving me crazy. Finding this issue #361 finally explains the strange behaviors I was seeing, which seemed to be bugs. For what it's worth, I "vote" for this issue, because removing local packages to prevent their use (e.g., unwanted used of vibe.d, resulting in an error that I have two main() functions) is quite user unfriendly.

In any case, is this a bug?

{
    "name": "ddbtest",
    "description": "A test case for ddb.",
    "copyright": "Copyright © 2014, luismarques",
    "authors": ["luismarques"],
    "dependencies": {
        "ddb": "~>0.2.2",
        "vibe-d": "~>0.7.21"
    },
    "subConfigurations": {
        "vibe-d": "v2"
    },
    "configurations": [
        {
            "name": "v1",
            "targetType": "executable",
            "versions": ["v1"]
        },
        {
            "name": "v2",
            "targetType": "executable",
            "versions": ["v2", "VibeDefaultMain"]
        }
    ]
}
$ dub run --config=v1
Fetching vibe-d 0.7.21 (getting selected version)...

That is, I want to declare vibe.d a dependency, but only for configuration v2. Yet, when I try to build configuration v1 it fetches vibe.d, which is fatal in the presence of issue #361.

@s-ludwig
Copy link
Member Author

s-ludwig commented Apr 6, 2015

The correct package description looks like this:

{
    "name": "ddbtest",
    "description": "A test case for ddb.",
    "copyright": "Copyright © 2014, luismarques",
    "authors": ["luismarques"],
    "dependencies": {
        "ddb": "~>0.2.2"
    },
    "configurations": [
        {
            "name": "v1",
            "targetType": "executable",
            "versions": ["v1"]
        },
        {
            "name": "v2",
            "targetType": "executable",
            "dependencies": {
                "vibe-d": "~>0.7.21"
            },
            "versions": ["v2", "VibeDefaultMain"]
        }
    ]
}

"subConfigurations" selects the configuration used for the dependency, not the configuration in which the dependency is used. But for the latter case, you can also declare a "dependencies" field inside of a configuration.

s-ludwig added a commit that referenced this issue Dec 11, 2015
If no dub.selections.json file exists yet, optional dependencies will stay deselected by default, unless the "default" flag is set. If dub.selections.json exists, optional dependencies will only be used if present in that file, independently of their local installation state.
s-ludwig added a commit that referenced this issue Dec 11, 2015
s-ludwig added a commit that referenced this issue Dec 11, 2015
If no dub.selections.json file exists yet, optional dependencies will stay deselected by default, unless the "default" flag is set. If dub.selections.json exists, optional dependencies will only be used if present in that file, independently of their local installation state.
s-ludwig added a commit that referenced this issue Dec 11, 2015
s-ludwig added a commit that referenced this issue Dec 16, 2015
If no dub.selections.json file exists yet, optional dependencies will stay deselected by default, unless the "default" flag is set. If dub.selections.json exists, optional dependencies will only be used if present in that file, independently of their local installation state.
s-ludwig added a commit that referenced this issue Dec 16, 2015
s-ludwig added a commit that referenced this issue Feb 10, 2016
If no dub.selections.json file exists yet, optional dependencies will stay deselected by default, unless the "default" flag is set. If dub.selections.json exists, optional dependencies will only be used if present in that file, independently of their local installation state.
s-ludwig added a commit that referenced this issue Feb 10, 2016
s-ludwig added a commit that referenced this issue Feb 10, 2016
If no dub.selections.json file exists yet, optional dependencies will stay deselected by default, unless the "default" flag is set. If dub.selections.json exists, optional dependencies will only be used if present in that file, independently of their local installation state.
s-ludwig added a commit that referenced this issue Feb 10, 2016
s-ludwig added a commit that referenced this issue Feb 10, 2016
s-ludwig added a commit that referenced this issue Feb 12, 2016
…-dependencies

Implement new optional dependency semantics. Fixes #361.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants