Closed donaldpipowitch closed 7 years ago
@jonathantorley I just tried it again with --force
and it still does not work with yarn 1.12.3
For others facing this issue: one workaround that I used to actually get this to work was to increase the version number of the dependent package. A bit annoying, and you have to remember to do it on each change (unless you can script it).
yarn
should definitely not require this workaround when installing local packages
I added yarn upgrade MY_PACKAGE_NAME
in preinstall
script, and it upgrades to the latest NPM version well. (Still, I need to bump the NPM version manually).
It seems yarn add file:PATH
now always upgrade the new content now in yarn 1.13.0.
yarn install
still not.
@leavesster Still doesn't for me.
I have to rename the tgz in order for it to update
Try using the link
command: https://yarnpkg.com/lang/en/docs/cli/link/
yarn add file:PATH
did not upgrade the new content for me. Moreover, files in package.json and .npmignore are not respected.
It works of you change the version of your package.
If you want yarn add file:PATH
to respect files in package.json and .npmignore, you must run yarn pack
in your local package dependency and then where you want to install it run yarn add file:path-to-local-pacckage.tgz
Try using the
link
command: https://yarnpkg.com/lang/en/docs/cli/link/
yarn link
is not intended to answer the same problem. It is not good if someone wants the npm package like if it was published respecting the files in package.json and .npmignore
@leavesster Still doesn't for me.
I have to rename the tgz in order for it to update
I don't have any tgz
in my package which I use yarn add file: PACKAGE_PAH
to add it in the current project. I just have js code in my the package. Maybe tgz still wrong ?
not working for me either
@bestander why this issue closed? Yarn still caching local files and tgz packages. Workspaces is not a solution in some cases, for example if one package have deps with specific versions, and other package have devDeps same packages as the first, but with another versions, and if you link one package into another, your project have been broken.
I have same issue as @gregjacobs. yarn cache clean package
didn't help. But I figured out that if you install yarn add path/to/package.tgz
and then replace archive to another one, you can install new version simply change the path like yarn add path/to/../to/package.tgz
, so absolute path is same, but for yarn its different.
I don’t understand where else yarn store cached packages by resolution path, even yarn cache list --pattern package
is empty.
I think the problem is somewhere here https://github.com/yarnpkg/yarn/blob/eb2b565bb9b948e87b11119482ebc184a9d66141/src/resolvers/exotics/tarball-resolver.js#L58-L63
Whats happening:
path/to/package.tgz
generates hash (that's why path/to/package.tgz
and path/to/../to/package.tgz
results to different hashes)/Users/kich/Library/Caches/Yarn/v4/.tmp/c019816ee7d10ed5e1fef4072e8cc617
)isValidModuleDest
return false
and all goes rightisValidModuleDest
return true
yarn cache clean package
, but temp directory remains untouched@bestander can we simply remove temp directory here https://github.com/yarnpkg/yarn/blob/master/src/config.js#L431 ?
Facing the same problem, the cache under temp folder takes 10GB after I work on my local pacakge for only one day!
Can we reopen this issue? We are facing the same problem. Two projects referencing another package via file:
I think the link protocol is the best fix for this, file:// doesn't work since it still requires manually clean caches & force installing
https://github.com/yarnpkg/yarn/issues/2165#issuecomment-345825904
just make your dependency something like this
"<package>": "link:./libs/<package>"
@alxtz does links protocol works with packages in tgz?
I think the link protocol is the best fix for this, file:// doesn't work since it still requires manually clean caches & force installing
just make your dependency something like this
"<package>": "link:./libs/<package>"
Thanks for this this replicates the behaviour of NPM which will symlink file:..
references in node_modules
. It does not appear to be documented, at least not here where I would expect to find it: https://yarnpkg.com/lang/en/docs/package-json/
Sadly, link
can't be used in all cases.
For example, I need a shared/peer dependency from my SDK package, which when I make changes, I would link for local dev work.
With link
, yarn does not realise that the dependency is a shared/peer dependency and uses the local package where the symlink is, which is incorrect.
I've been using yarn pack
alongside yarn add file:<path_to_packed_tgz>
to get around this.
Whilst I can continue to rename the package every time I pack it and paste it into my repo, so as not to generate the same hash, as per @wKich fantastic find, it's damn annoying.
I forked the repo and put an extra clause in the if statement to stop yarn from ever loading a local .tgz package from its cache if it's specified using yarn add file:<path>
.
const dest = this.config.getTemp(crypto.hash(url));
// If specified using file: never load from cache
if (!url.match(/file:/) && (await this.config.isValidModuleDest(dest))) {
// load from local cache
} else {
// continue as if it's a new package
}
I can make a PR if people want it, though I've never done that before and it's a pretty hacky fix. Could someone confirm if this approach would continue to add the local packages to yarn's cache or not, please?
@ojboj for now, yalc
might help until this gets a proper fix. It has been working really well for me to test packages locally before publishing.
@souporserious That is exactly what I needed/wanted, thank you so much!
Insane this is still an issue after so many years.
Is it fixed in yarn@2.x?
@wKich I believe so! I haven't personally tested it, but it looks like they solve local development through the new portal protocol.
I still get "unpack in same destination" error using the link:
protocol, and it's referencing my cache dir, so it seems to me yarn is still caching link:
dependencies. I'm referencing 2 copies of the same local package, copied into the .deps/
folder of each app that uses it -- front-end
and renderer
in the error below. (Can't link to the original for unrelated reasons)
warning Pattern ["@horizon/common@link:packages/front-end/.deps/@horizon/common"] is trying to unpack in the same destination "/home/garyo/.cache/yarn/v6/npm-@horizon-common-0.1.0/node_modules/@horizon/common" as pattern ["@horizon/common@link:packages/renderer/.deps/@horizon/common"]. This could result in non-deterministic behavior, skipping.
This issue is not fixed by the link:
and portal:
protocols for those of us like @ojboj and me who install packages from a tarball instead of a directory, e.g. file:path/to/dependency.tgz
. One annoying workaround is to use a throwaway cache directory like yarn install --cache-folder $(mktemp -d)
. My preferred workaround is to just bust the cache for every offline dependency: rm -rf $(yarn cache dir)/.tmp
. Thanks to @wKich for the detective work.
Why is this closed? I still get this issue in Yarn 1.22.19... Yarn caches local packages, which is not helpful for development.
Believe it or not, it's still an issue with yarn berry (3+). I wish there were better alternatives to deal with devDeps.
It is actually 4+ years https://github.com/yarnpkg/yarn/issues/6037
When developing a package with React 18 I had various issues using yarn link
, so I just rely on building a local package and installing in my React app, this issue is pretty annoying... there should be some way to forcefully reinstalling the single local package ignoring the cache instead of using yarn cache clean
.
Do you want to request a feature or report a bug?
I guess a bug.
What is the current behavior? If the current behavior is a bug, please provide the steps to reproduce.
Say you have the following project structure:
With the following files:
component-foo/package.json
:component-foo/index.js
:yarn-test/package.json
:Now you run
$ yarn install
insideyarn-test/
andyarn-test/node_modules/component-foo/index.js
is:Now remove
yarn-test/node_modules/
andyarn-test/yarn.lock
and changecomponent-foo/index.js
to this:Now you run
$ yarn install
insideyarn-test/
again andyarn-test/node_modules/component-foo/index.js
will be:It uses the cached version of
component-foo
, butcomponent-foo/index.js
has changed.What is the expected behavior?
I'd expect that
yarn-test/node_modules/component-foo/index.js
should be this at the end:Maybe packages installed with local paths like
file:../
shouldn't be cached at all, if we can't figure out, if they have changed.(FYI: It looks like npm doesn't cache them.)
Please mention your node.js, yarn and operating system version.