Giter VIP home page Giter VIP logo

Comments (7)

devoncarew avatar devoncarew commented on August 12, 2024

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/create.dart#L131

from path.

nex3 avatar nex3 commented on August 12, 2024

This looks correct to me. It satisfies the invariant that p.join(from, p.relative(path, from: from)) refers to the same path as path.

import 'package:path/path.dart' as p;

void main() {
  var from = "/var/folders/00/0w978000h01000cxqpysvccm003j4x/T/flutter_toolsZUIVMq";
  var path = "/Users/devoncarew/projects/flutter/flutter/packages";

  print(p.normalize(from, p.join(p.relative(path, from: from))));
  // => /Users/devoncarew/projects/flutter/flutter/packages
}

Keep in mind that the from argument takes the place of the current directory. So if flutter_toolsZUIVMq is a file and you want a relative path that is valid within that file, from should be /var/folders/00/0w978000h01000cxqpysvccm003j4x/T.

from path.

devoncarew avatar devoncarew commented on August 12, 2024

flutter_toolsZUIVMq is a directory - we're creating a pubspec file in there and trying to write a relative path from there to the flutter package. (flutter_toolsZUIVMq/pubspec.yaml)

from path.

nex3 avatar nex3 commented on August 12, 2024

In that case, the path you listed should work. I count six ..s, which matches the six path segments in from.

from path.

devoncarew avatar devoncarew commented on August 12, 2024

But from flutter_toolsZUIVMq, it's only 5 segments up.

What's odd is that this test works on linux. And it does look like the relative path being created in the pubspec is bad.

from path.

nex3 avatar nex3 commented on August 12, 2024

But from flutter_toolsZUIVMq, it's only 5 segments up.

Not if it's a directory and you're resolving a path inside it. You still have to .. up through flutter_toolsZUIVMq.

What's odd is that this test works on linux. And it does look like the relative path being created in the pubspec is bad.

I suspect the real issue here is OS X's symlinking of the /tmp directory. Relative paths that move up out of symlinked directories are unreliable; they can be resolved differently depending on what the resolving entity thinks the current working directory's path is.

from path.

devoncarew avatar devoncarew commented on August 12, 2024

Ah, something to look into. I'll see if canonicalizing the paths helps.

from path.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.