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

Can't rename a dependency package in pubspec.yaml #563

Closed
DartBot opened this issue Jun 5, 2015 · 4 comments
Closed

Can't rename a dependency package in pubspec.yaml #563

DartBot opened this issue Jun 5, 2015 · 4 comments
Labels
closed-as-intended Closed as the reported issue is expected behavior type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/1721046?v=3" align="left" width="96" height="96"hspace="10"> Issue by alextekartik
Originally opened as dart-lang/sdk#10940


This is a feature request

I managed to add a relative path dependency in my app

  name: myapp
  description: A sample app
  dependencies:
    mylib:
      path: ../mylib

and then import it in my source code

  import 'package:mylib/mylib.dart';

However, the name 'mylib' is taken from the library package pubspec and if I want to change it (for example 'mynewlib'), I have to change the name everywhere (pubspec AND dart source code)

It also prevent having 2 packages with the same name (yes I know, weird, but I don't control what people put in pub.dartlang.org). What I'd like to do is something like

  name: myapp
  description: A sample app
  dependencies:
    mylib:
      path: ../mylib
      name: mynewlib

and have in source code

  import 'package:mynewlib/mylib.dart';

However I cannot find the proper syntax and whether that's possible or not. (Sample code ready for testing is here: https://github.com/alextekartik/dart-test/tree/master/lib_test). To note that here I'm not talking about library name but package name (and naming the package mylib can be confusing)

See here: http://stackoverflow.com/questions/16791441/is-it-possible-to-give-a-different-name-to-a-package-dependency-in-pubspec

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/5449880?v=3" align="left" width="48" height="48"hspace="10"> Comment by iposva-google


Removed Priority-Medium label.
Added Priority-Unassigned, Area-Pub, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Pub by design doesn't let you change the name of a package outside of its own pubspec. There are a couple of problems allowing this can cause:

  1. When the package imports its own libraries using "package:oldname/...", that import will fail if you instead rename it to "newname".
  2. Other code you import that is importing the package using its old name would fail to find it.

We could maybe figure out some way to make this work, but my intuition is this would add a lot of complexity to pub without that much benefit in return, but maybe there are some motivating use cases I'm not seeing?


Added AsDesigned label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/1721046?v=3" align="left" width="48" height="48"hspace="10"> Comment by alextekartik


Package name collision as reported in this thread https://groups.google.com/a/dartlang.org/forum/#!topic/misc/u5WOIYMntgU could be added as a "motivating use case"

@DartBot DartBot added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) closed-as-intended Closed as the reported issue is expected behavior labels Jun 5, 2015
@DartBot DartBot closed this as completed Jun 5, 2015
@sumanpula
Copy link

-> Select main or root folder of the source code, for ex. lib folder
-> Right click and select "Replace in Path" option
-> Then Replace the path that you want to reflect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-as-intended Closed as the reported issue is expected behavior type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants