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

test(integration): Adds assertion to exemplify wrong path resolution in lock file #4717

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

joscha
Copy link

@joscha joscha commented Oct 16, 2017

The added assertions make sure that the relative path generated in the lock file points to the
installation, not the yarn cache

This exemplifies the problem outlined in #4388:

1__yarn_test_----watch__node__and_integration_js _yarn

@joscha
Copy link
Author

joscha commented Oct 16, 2017

Error seems to be produced here:

return path.join(this.cacheFolder, `${name}-${uid}`);
where the cache path is used as a starting point to generate an absolute path, coming from:

loc = this.config.generateHardModulePath(ref);

and further when the dependency gets resolved initially, where it should have been something more similar to a 'workspace' type instead of a 'copy' type:

@BYK
Copy link
Member

BYK commented Oct 26, 2017

Hi @joscha! Thanks for the PR! Obviously, we cannot merge this since it breaks CI :)

Are you planning to submit a fix for the problem? If not can we have this test split up and skip the failing part so we can keep the code and the CI?

@joscha
Copy link
Author

joscha commented Oct 26, 2017

Hi @BYK - I opened the PR to illustrate the problem outlined in #4388 in a test. This is currently blocking us from upgrading from 0.27.5 to 1.x, so I would love to provide a fix. Unfortunately, I dug around in the code and can't perfectly pinpoint where the fix will need to be made, as there are a few places where it could be, but I think something more general needs correction than a simple path fix, hence my comment #4717 (comment) - do you know anyone I could have a short chat with to find out in which module the fix would live?

@BYK
Copy link
Member

BYK commented Oct 31, 2017

@joscha - sorry for the late responses. Unfortunately, PRs are not the best place to have quick conversations anymore 😄 Come to our Discord Channels anytime and ping me or anyone really to initiate a chat. I feel like this issue is somewhat related to #3453.

I'll do some more digging and come back to you. Thanks a lot for sticking with us although us not responding very quickly :)

@BYK
Copy link
Member

BYK commented Oct 31, 2017

@joscha I've pushed some changes to your branch and did some hacky things to fix the issue but I think we need a larger refactoring here.

@rally25rs @arcanis @kaylieEB - Please have a look at the new code now. It also fixes #3453. I think this is super-hacky but maybe it is an "OK" start and we can start fixing these intermingled parts?

@BYK BYK requested review from rally25rs and removed request for bestander October 31, 2017 17:25
@BYK BYK self-assigned this Oct 31, 2017
@BYK
Copy link
Member

BYK commented Oct 31, 2017

Woo, I've broken so many other tests now :D

@@ -5,11 +5,10 @@ import BaseFetcher from './base-fetcher.js';
import * as fs from '../util/fs.js';

export default class CopyFetcher extends BaseFetcher {
async _fetch(): Promise<FetchedOverride> {
await fs.copy(this.reference, this.dest, this.reporter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this copy anywhere else, just removed. Was it not needed? Is something else performing the copy now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since "file" dependencies are already on the disk, they are now copied at the linking stage, directly from the source instead of from the cache folder.

src/config.js Outdated
@@ -395,6 +395,10 @@ export default class Config {
return pkg.location;
}

if (pkg.remote.type === 'copy') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The couple pkg.remote.type === 'copy' checks feel like an implementation detail that should be left to the remote. (leaky abstraction?) Perhaps this module path creation should be part of the remote and not part of config (config feels like a weird place for it anyway).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree. I think we need to extend the remote information to allow "directly available" packages. This may become useful for other things in the future but I don't know how directly. Right now it feels specific to link: and file: protocols so I was unsure about extending this data structure or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like tarball-resolver can also report a type of copy. Not sure if that is OK or not...

    // set remote so it can be "fetched"
    pkgJson._remote = {
      type: 'copy',
      resolved: `${url}#${hash}`,
      hash,
      registry,
      reference: dest,
    };

Copy link
Contributor

@rally25rs rally25rs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the CI failures are not actually related to this PR, 👍 (edit: looking at the CI results, it's hard to tell what's causing these...)

@joscha
Copy link
Author

joscha commented Nov 6, 2017

\o/

@joscha
Copy link
Author

joscha commented Nov 13, 2017

@BYK any chance to get this in?

@joscha
Copy link
Author

joscha commented Nov 24, 2017

@BYK is the general gist of the changes in this PR what we want to do? If yes, I can try and make tests go green.

@BYK
Copy link
Member

BYK commented Nov 27, 2017

@joscha I guess so. I feel like this requires a bit more refactoring around how we use cache and assume it is there so not sure if it would be fun times for you to figure that out. That said if you really want to try, who am I to stop an enthusiastic soul? 😁

@joscha
Copy link
Author

joscha commented Nov 27, 2017

That said if you really want to try, who am I to stop an enthusiastic soul?

😆 haha, hence my question if the general approach is fine, because looking at the code right now, I couldn't definitely say it is. Are there user stories somewhere, e.g. When I have a local file:-dependency, then I expect the files to be copied into the node modules folder and the yarn cache not to be populated, etc.?

@BYK
Copy link
Member

BYK commented Nov 27, 2017

When I have a local file:-dependency, then I expect the files to be copied into the node modules folder and the yarn cache not to be populated, etc.?

I don't think there's a user scenario but since file: dependencies are local, unless you have used yarn link they should never have been copied to cache in the first place if you ask me. This is what I mean with larger refactoring. Right now, Yarn tries to load everything from the cache folder with the exception of links. That most probably needs to change but it didn't look too easy when I last tried.

@joscha
Copy link
Author

joscha commented Nov 27, 2017 via email

@BYK
Copy link
Member

BYK commented Nov 27, 2017

@joscha I feel like it is fine to sync/copy at all times. That would be a divergence from the old npm behavior but would align with the new npm behavior where file: is treated as link: since I think that's what the developers expect anyway. In that case, bypassing the cache makes sense. Even if we want to use the cache, we need to namespace these packages so they don't collide with things from other registries etc.

@joscha
Copy link
Author

joscha commented Feb 27, 2018

This seems to be fixed in 1.5.1. I propose to get the tests in, to ensure it won't be broken in the future by accident.

@arcanis
Copy link
Member

arcanis commented Feb 27, 2018

@joscha Do you mind rebasing the PR? I'll see to merge it!

…in lock file

The added assertions make sure that the relative path generated in the lock file points to the
installation, not the yarn cache

yarnpkg#4388
@joscha joscha force-pushed the joscha/relative-paths-cache-dir branch from 854fb1b to c0ec6eb Compare February 27, 2018 21:20
@joscha
Copy link
Author

joscha commented Feb 27, 2018

rebased @arcanis

@buildsize
Copy link

buildsize bot commented Feb 27, 2018

This change will decrease the build size from 10.49 MB to 10.49 MB, a decrease of 5.33 KB (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 909.34 KB 908.96 KB -393 bytes (0%)
yarn-[version].js 3.95 MB 3.95 MB -2.21 KB (0%)
yarn-legacy-[version].js 4.1 MB 4.1 MB -2.2 KB (0%)
yarn-v[version].tar.gz 914.8 KB 914.26 KB -552 bytes (0%)
yarn_[version]all.deb 675.21 KB 675.22 KB 12 bytes (0%)

@joscha
Copy link
Author

joscha commented Feb 27, 2018

ah, I am not sure what I am seeing locally with 1.5.1 - seems this problem still exists in master...

@joscha
Copy link
Author

joscha commented Feb 27, 2018

Just tested again locally. I am unsure what the hiccup was, but this problem still exists in 1.5.1 unfortunately.

@tsdorsey
Copy link

Forgive me if this is unrelated but another consideration when tackling this issue is that yarn will convert absolute paths in package.json to relative ones in yarn.lock. In my use case, that breaks things (which I can expound upon if need be but I do not think relavant). I would expect that a local dependency (absolute or relative path) should not be altered by the yarn.lock generation process.

@joscha
Copy link
Author

joscha commented Jun 12, 2018

@arcanis I fixed the merge commit up, you can now see the problem again.

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

Successfully merging this pull request may close these issues.

None yet

5 participants