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

tns_modules randomly appears in app folder and breaks build #3016

Closed
thaoula opened this issue Jul 29, 2017 · 12 comments
Closed

tns_modules randomly appears in app folder and breaks build #3016

thaoula opened this issue Jul 29, 2017 · 12 comments
Assignees
Labels
Milestone

Comments

@thaoula
Copy link

thaoula commented Jul 29, 2017

Hi Guys,

A folder called tns_modules is randomly added to the app folder. The contents seem to be a subset of node_modules.

Once the folder appears, you cannot use tns run / build etc. Deleting the folder fixes these issues.

Why does tns_modules get created?

I am using TNS 3.1.3 on a Mac, this happened in 3.1.0 as well.

Regards,
Tarek

@dtopuzov
Copy link
Contributor

Hi @thaoula

Can you specify version of node and npm on your machines?
If you can also isolate workflow that reproduce the issue it will be great.

@dtopuzov dtopuzov added the bug label Jul 31, 2017
@thaoula
Copy link
Author

thaoula commented Jul 31, 2017

Hi @dtopuzov,

I am using npm 5.3.0 and node 8.

I am still trying to identify the workflow that causes tns_modules to be created. Unfortunately, i have been unable to work out any repeatable steps.

However, it happened several times yesterday.

Regards,
Tarek

@dtopuzov
Copy link
Contributor

dtopuzov commented Aug 1, 2017

Hi @thaoula

Thanks for the info.
Two more questions:

  • Do you use npm link in your development workflow?
  • Do you use some dev plugins like nativescript-dev-sass or nativescript-dev-less (something that modify files in the project while you develop)?

@thaoula
Copy link
Author

thaoula commented Aug 1, 2017

Hi @dtopuzov,

Thanks for getting back to me -
I use nativescript-dev-less and I also use npm link for our model project.

Is there anyway to debounce watches or ignore files?

Regards,
Tarek

@dtopuzov
Copy link
Contributor

dtopuzov commented Aug 2, 2017

Hi @thaoula

We do not have such feature available at the moment, but it is in the backlog: #887

The issue seems to happen only if you have npm5 and use npm link.
We will try to fix it for next release(s) and until then you can try to workaround it via downgrade to npm4.

@Plamen5kov
Copy link
Contributor

@thaoula If you could provide us with the steps to reproduce the issue, that will contribute to how fast it will be fixed. Thank you!

@etabakov etabakov removed this from the 3.2.0 milestone Aug 15, 2017
@kmuthukrishnan
Copy link

Hi @dtopuzov
Am having the same problem and am not using npm link in the development workflow.
Also not using dev plugins like nativescript-dev-sass or nativescript-dev-less.

Once I delete the tns_modules folder everything works.
Thanks

@mikebranstein
Copy link

I've run into this issue multiple times, and I'm using NPM 6.10.1. I don't use npm link and do not use nativescript-dev-sass or nativescript-dev-less.

@dvdbrk
Copy link

dvdbrk commented Sep 8, 2017

NPM 3.10.10, with nativescript-dev-sass, and the same issue exists.

@RobertGardner
Copy link

I just had app/tns_modules created when I ran tns install. I had never used that before and instead have used npm install, which correctly places the modules in ./node_modules.

@AdamDenoon
Copy link

I was having the same problem (tns_modules appearing and the build not working) with {N} 3.2.1, only when I ran on the iOS 11 Simulators. The following commands fixed my issue:

tns platform remove ios
tns platform add ios

@rosen-vladimirov
Copy link
Contributor

rosen-vladimirov commented Oct 10, 2017

Hey all,
I've finally reproduced the issue and found what's causing it. It's pretty tricky, but I'll try to explain it with full details.
The issue can be reproduced only when using iOS Simulator. For communication with simulators, CLI uses a library called ios-sim-portable. We have extracted the code for communication with the simulator in this library for easier maintenance. The ios-sim-portable library spawns xcrun simctl commands in order to get required information. In order to use sync code, we are using spawnSync method of Node.js. However, this method has some "specialties". The problem here is that sending any kill signal to CLI (like Ctrl + C, which sends SIGINT) while spawnSync is working may not be propagated to CLI's main process. This may happen in case the spawned executable (xcrun simctl in this case) handles the signal on its own. And of course, that's our case. So using Ctrl + C while ios-sim-portable is currently working with xcrun simctl will just make the spawned process to die, but CLI will continue its work.
And here comes the second part of the issue - during LiveSync (tns run ios) CLI is trying to get the path where to send the synced files. In order to find the place, CLI calls ios-sim-portable, which executes xcrun simctl get_app_container <device id> <app id>. In case SIGINT is send during execution of this command, ios-sim-portable will return empty string and CLI will add app/tns_modules to it. So the path, where CLI will try to copy files for LiveSync becomes ./app/tns_modules. CLI's process continues its work and starts copying files to ./app/tns_modules.

The xcrun simctl commands are executed really fast, so its tricky to reproduce the issue. You have to try tns run ios and press Ctrl + C exactly when the xcrun simctl get_app_container is spawned. However, I've managed to reproduce it by hanging the iOS Simulator itself. I've started tns run ios in two separate terminals for the same project (note: the second command is started some time after the first one). At some point I've stopped both processes with Ctrl + C and tried calling the xcrun simctl get_app_container <device id> <app id> manually and it just hanged. So after that, executing tns run ios hangs at some point, waiting for the result of the mentioned command. At this point, pressing Ctrl + C should kill CLI, however it just continues and creates the tns_modules dir in app of the project.

In order to fix the issue, we'll update ios-sim-portable to respect the signal property of the result of the spawned process and ensure it is correctly passed to CLI as well. This way, pressing Ctrl + C will be sent to both xcrun commands and to CLI and the tns_modules directory will not be created on incorrect place, as CLI's process will die as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants