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]: With an nx.json config, npx cap sync hooks (capacitor:sync:before and capacitor:sync:after) are executing from the node_modules instead of the repo root #7606

Open
2 of 3 tasks
gabides opened this issue Aug 6, 2024 · 1 comment
Labels
cli type: bug A confirmed bug report

Comments

@gabides
Copy link

gabides commented Aug 6, 2024

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.1.1
@capacitor/core: 6.1.1
@capacitor/android: 6.1.1
@capacitor/ios: 6.1.1

Installed Dependencies:

@capacitor/android: not installed
@capacitor/cli: 6.1.1
@capacitor/core: 6.1.1
@capacitor/ios: 6.1.1

[success] iOS looking great! 👌

Other API Details

npm 9.5.0
node v18.15.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

This is a follow up to #7581 . Sorry for posting again but I could not manage to create a reproduction repo until now and the issue was closed today so I can't reply there. This comment from de-robat gave me a hint that it was coming from the fact that we are using nx in our repo.

As the reproduction repo suggests below, having an nx.json file inside the project will lead the npx cap sync command to execute at the root of each plugin inside the node_modules (once per plugin) starting with capacitor/cli 6.1.0, whereas:

  • if you delete nx.json, it executes only once, at the root of the repo
  • if you keep nx.json and downgrade capacitor/cli to version 6.0.1, it executes only once, at the root of the repo

Expected Behavior

Execute the capacitor:sync:before and capacitor:sync:after hooks only once and at the root of the repo (and not once per plugin inside the node_modules) when using an nx config and when the version of capacitor/cli is 6.1.0 (like it was in previous versions, e.g. 6.0.1)

If this is an intended behaviour, can you provide some documentation for it, or an alternative to prevent it as it is a change in the behaviour of the hooks of the sync command

Project Reproduction

https://github.com/gabides/capacitor-sample-app-sync-issue

Additional Information

the reproduction repo was created:

  • with the create-capacitor-app command line
  • fixing the package.json versions
  • adding an nx.json file
  • adding an ios project
  • adding a capacitor:sync:after hook
@gabides gabides added the triage label Aug 6, 2024
@jcesarmobile jcesarmobile added cli type: bug A confirmed bug report labels Sep 10, 2024
Copy link

ionitron-bot bot commented Sep 10, 2024

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

@ionitron-bot ionitron-bot bot removed the triage label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli type: bug A confirmed bug report
Projects
None yet
Development

No branches or pull requests

2 participants