You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "vbansal-bb (via GitHub)" <gi...@apache.org> on 2025/04/21 11:20:10 UTC
[I] SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL during command cordova platform add android [cordova-cli]
vbansal-bb opened a new issue, #661:
URL: https://github.com/apache/cordova-cli/issues/661
# Bug Report
## Problem
In certain scenario (when there are nodue modules in www folder having sym link) cordova platform add android command fails
### What is expected to happen?
Cordova platfprm add android should work as expected.
### What does actually happen?
it gives below error
Invalid src or dest: cp returned EINVAL (cannot copy /Users/vbansal/Documents/Cordova_Workspace/test/www/node_modules/glob/dist/esm/bin.mjs to a subdirectory of self /Users/vbansal/Documents/Cordova_Workspace/test/www/node_modules/glob/dist/esm/bin.mjs) /Users/vbansal/Documents/Cordova_Workspace/test/platforms/android/app/src/main/assets/www/node_modules/.bin/glob
## Information
It seems it gets confused due to to sym link if there in node_modules
If i delete www/node_modules/.bin then issues goes away.
### Command or Code
<!-- What command or code is needed to reproduce the problem? -->
Following are the steps to reproduce it 100%
cordova create test com.test.blank Testapp
cd test/www && npm init --yes
npm i jasmine
cd ..
cordova platform add android
### Environment, Platform, Device
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
Mac OS
Android
### Version information
<!--
What are relevant versions you are using?
For example:
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
Other Frameworks: Ionic Framework and CLI version
Operating System, Android Studio, Xcode etc.
-->
Cordova-
12.0.0 (cordova-lib@12.0.1)
Node JS: 18.x, 20.x both facing same issue
## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [x ] I searched for existing GitHub issues
- [x ] I updated all Cordova tooling to most recent version
- [ x] I included all the necessary information above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL during command cordova platform add android [cordova-cli]
Posted by "BigBalli (via GitHub)" <gi...@apache.org>.
BigBalli commented on issue #661:
URL: https://github.com/apache/cordova-cli/issues/661#issuecomment-4179806554
Hey — it looks like the root cause here is having `node_modules` inside the `www/` folder. Cordova copies everything in `www/` into the platform assets, and when symlinks are present (like the ones npm creates in `.bin/`), the `fs.cp` call chokes trying to copy a symlink that points back into itself.
Your workaround of deleting `www/node_modules/.bin` confirms this. The more permanent fix would be to avoid running `npm install` inside `www/` altogether — keep your frontend dependencies in the project root (or a separate `src/` folder) and use a build step to output only the final assets into `www/`. That way Cordova never tries to copy `node_modules` symlinks during `platform add`.
Have you tried that approach? Curious if it fully resolves it for your workflow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL during command cordova platform add android [cordova-cli]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #661:
URL: https://github.com/apache/cordova-cli/issues/661#issuecomment-4184172081
Yah I'm not sure if I'd consider this a bug. `www` directory should be reserved for files that are intended to be packages in your app for your runtime. node packages are typically not consumable by a traditional browser/webview environment and often require additional tooling to bundle any content. Additionally node_modules may have several other dependencies related to development but not necessary for your runtime.
But that could be subjective. The root issue is following symlinks. If we copied the symlinks as is, it may or may not work during the runtime, honestly not quite sure if webviews will follow symlinks. Even if it does, the symlink reference would need to be relative. If we resolved symlinks ahead of time and copied the canonical path, if your directory structure makes heavy use of symlinks it would be creating a lot of duplicate files. This would also fail if there is a circular reference in your symlinks.
Lastly symlinks can make it easy to bypass security mechanisms, so adding support for them isn't as easy as simply resolving symlinks.
So for those reasons I think we should consider symlinks as unsupported, and I don't think there was ever a time where symlinks was actually supported in full or even tested against.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL during command cordova platform add android [cordova-cli]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on issue #661:
URL: https://github.com/apache/cordova-cli/issues/661#issuecomment-2820008476
@vbansal-bb Does this happen with cordova-android 14.0.0? fs-extra is no longer used in newer versions of the Android platform.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL during command cordova platform add android [cordova-cli]
Posted by "vbansal-bb (via GitHub)" <gi...@apache.org>.
vbansal-bb commented on issue #661:
URL: https://github.com/apache/cordova-cli/issues/661#issuecomment-2820767871
@dpogue yes. it occurs with cordov android 14.0.0 as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] SystemError [ERR_FS_CP_EINVAL]: Invalid src or dest: cp returned EINVAL during command cordova platform add android [cordova-cli]
Posted by "vbansal-bb (via GitHub)" <gi...@apache.org>.
vbansal-bb commented on issue #661:
URL: https://github.com/apache/cordova-cli/issues/661#issuecomment-2818248754
I also guess that also this issue start appearing after fs-extra 11.3.0 release on 15 Jan.
Could this change (https://github.com/jprichardson/node-fs-extra/pull/1045/files)be the root cause ?
@cordova team please see if you like to fix the issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org