-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
install package with file: protocol as default if it exists in the filesystem and using fs.exists instead of using fs.existsSync #2723
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few nits
src/package-request.js
Outdated
|
||
async normalize(pattern: string): any { | ||
const {name, range, hasVersion} = PackageRequest.normalizePattern(pattern); | ||
const new_range = await this.normalizeRange(range); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do we use underscore for word separation anywhere in Yarn?
I think we should stick to the same camelCase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, resolved ;)
src/package-request.js
Outdated
return Promise.resolve(pattern); | ||
} | ||
|
||
if (await fs.exists(path.join(this.config.cwd, pattern))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often is this IO operation is used?
Can we infer if pattern looks like a file first before touching the disk if this happens often?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some over-thinking we can do something like this:
if (pattern.includes(':') ||
pattern.includes('@') ||
PackageRequest.getExoticResolver(pattern)) {
return Promise.resolve(pattern);
}
this should give us enough confidence that the pattern may be a file if we go ahead in the method. Do you like it? Do you think is enough?
b7cc7d5
to
80fe1c0
Compare
80fe1c0
to
ce63d24
Compare
Thanks for the fix, @voxsim and for doing a quick turnaround! |
greetings. Very new to yarn. Loving it. I believe this particular PR has broken local tgz file installation.
This mechanism worked in 0.22, but fails in 0.23 Now we are seeing:
Happy to file a bug or take any advise |
hey @kjbkjb, have you tried with another version of the same package? Because the issue it does not seem related, i mean really the server doesn't have that version of the package. Btw if you think it is a real issue, maybe it's better to open an issue and link this pull request ;) |
I've tried building several fresh versions. if the version did not exist before and it was not listed in the lock file, version 0.22 would find the file in the local file system, but 0.23 tries to look up the module on npm and ignores the local file. This pr was dealing with file installation so I thought it looked suspicious. I'll file an issue. |
This pull request should resolve #605 and it is related to #2684.
In this case we use
fs.exists
instead of usingfs.existsSync
.cheers,
voxsim