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

[BUG] cacache doesn't work on Android #155

Closed
1 task done
licy183 opened this issue Nov 21, 2022 · 7 comments · Fixed by #195
Closed
1 task done

[BUG] cacache doesn't work on Android #155

licy183 opened this issue Nov 21, 2022 · 7 comments · Fixed by #195
Labels
Bug Needs Triage needs an initial review

Comments

@licy183
Copy link

licy183 commented Nov 21, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

~ $ npm install yarn
npm ERR! code EACCES
npm ERR! syscall link
npm ERR! path /data/data/com.termux/files/home/.npm/_cacache/tmp/14de33dd
npm ERR! dest /data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/d1/d2/d481d770644c0c5e31275a2b952a18da6097da58f146549fb26a5f5d8ac389ffcd10db5d924df1176590499cd2d92b5c21f948efab003774723c809d2d6c
npm ERR! errno EACCES
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 10427:10427 "/data/data/com.termux/files/home/.npm"

npm ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2022-11-21T01_31_59_253Z-debug-0.log

Expected Behavior

NPM install package successfully.

Steps To Reproduce

In Termux, run

apt update && apt upgrade 
apt install nodejs-lts
npm install -g npm@9.1.2
npm install yarn

Then error message will occur.

fs.link will try to use hard link, which is disallowed by seccomp in Android. The maintainer of termux packages have applied a patch to solve this, but when users update cacache or npm, the patch will not work anymore.

Related issues: termux/termux-packages#11293, termux/termux-packages#13293
Possible patch: https://github.com/termux/termux-packages/blob/master/packages/nodejs/deps-npm-node_modules-cacache-lib-util-move-file.js.patch

Environment

  • npm: 9.1.2
  • Node: 16.18.1
  • OS: Android
  • platform: Termux 0.118
@licy183 licy183 added Bug Needs Triage needs an initial review labels Nov 21, 2022
@licy183 licy183 closed this as completed Jan 6, 2023
@licy183 licy183 reopened this Jan 6, 2023
@papb
Copy link

papb commented Jan 11, 2023

Thank you so much for investigating this. Hopefully a solution will be applied soon.

I noticed that the "possible patch" you linked above is present in the Termux repository, and I noticed there are other .patch files there too, I am wondering how does that work? Is it possible that Termux applies the patch in a forced way themselves, so that we don't really have to wait for a fix on the original package? Or is it something else?

@licy183
Copy link
Author

licy183 commented Jan 12, 2023

Thank you so much for investigating this. Hopefully a solution will be applied soon.

I noticed that the "possible patch" you linked above is present in the Termux repository, and I noticed there are other .patch files there too, I am wondering how does that work? Is it possible that Termux applies the patch in a forced way themselves, so that we don't really have to wait for a fix on the original package? Or is it something else?

When building packages for Termux, the building system of Termux packages will apply this patch to the sources, thus the deb files will contain a patched npm. But when npm is updated, the patched files will be overridden by the files from official package, so this patch will not work anymore.

@papb
Copy link

papb commented Jan 14, 2023

But from the way you said it, it looks like npm should work right after installing in termux, as long as I don't update npm, but as mentioned in the other issue this is not the case, why?

@licy183
Copy link
Author

licy183 commented Jan 14, 2023

But from the way you said it, it looks like npm should work right after installing in termux, as long as I don't update npm, but as mentioned in the other issue this is not the case, why?

Because npm you installed through apt/pkg install nodejs contains patched files, the moveFile function will not call fs.link. But if you update it manually, the patched file will be overridden.

@papb
Copy link

papb commented Jan 16, 2023

Sorry if I wasn't clear, that's not what I tried to ask. My question is: considering the patch exists, why do I still get an error, even if I don't update npm manually?

@licy183
Copy link
Author

licy183 commented Jan 16, 2023

Sorry if I wasn't clear, that's not what I tried to ask. My question is: considering the patch exists, why do I still get an error, even if I don't update npm manually?

Emmm... I have no idea. After a fresh install of nodejs, the move-file.js in $PREFIX/lib/node_modules/npm/node_modules/cacache/lib/util should only contains a workable moveFile function. If you still get the same error after a fresh install of nodejs through apt or pkg, please report this bug to https://github.com/termux/termux-packages.

@moltar
Copy link

moltar commented Apr 26, 2023

I know this is truly an edge case, but I am running into this linking issue when using a mounted fs that does not support links (s3fs-fuse).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage needs an initial review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants