Comments (7)
from path.
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.
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.
In that case, the path you listed should work. I count six ..
s, which matches the six path segments in from
.
from path.
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.
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.
Ah, something to look into. I'll see if canonicalizing the paths helps.
from path.
Related Issues (20)
- package website unreachable HOT 1
- Windows paths shouldn't be canonicalized to lower-case HOT 2
- Exception: NoSuchMethodError: The method 'pathFromUri' was called on null. HOT 4
- Support \\?\ prefix in UNC Windows paths HOT 2
- [Question] Is it possible to enforce style or context? HOT 1
- please support package's protocol path HOT 1
- setExtension removes part of a filename if it contained dot
- setExtension removes part of a filename if it contained dot HOT 1
- flutter_test from sdk depends on path 1.8.0 HOT 8
- `isWithin` has surprising behavior when `base` ends with `/.` and `child` starts with `.` HOT 1
- does not parse ~ HOT 1
- Version 1.8.1. `path.posix` has many bugs. HOT 1
- Error by installing path 1.8.1 HOT 1
- version solving failed HOT 1
- Why does .dirname(String) return '.' instead of '' when passed an empty (non-null) string HOT 1
- Getting `version solving failed` with using 1.8.3 version HOT 1
- isAbsolute(r'\') should return false for Windows-style filesystem HOT 4
- pathContext.fromUri() mishandles encoded colons after drive letters HOT 4
- absolute() either should automatically normalize paths or docs should emphasize that it doesn't HOT 3
- Can the latest version be compatible with the latest stable version of Flutter? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from path.