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

Allow to specify the workspace path in CLI argument #2842

Closed
yannickglt opened this issue Apr 10, 2020 · 3 comments
Closed

Allow to specify the workspace path in CLI argument #2842

yannickglt opened this issue Apr 10, 2020 · 3 comments

Comments

@yannickglt
Copy link
Contributor

yannickglt commented Apr 10, 2020

Nx computing cache improved a lot our CI build times. Thanks for that 😍.

Now, the most of the build time is occupied by NPM dependencies installation and Ngcc build.
To solve this, we decided to cache the node_modules folder and create symbolic links onto builds with same dependencies.

However, the Nx cli cannot be run through linked node_modules currently as it uses __dirname to retrieve the local workspace.

Using process.cwd() instead of __dirname makes the cli work and the whole CI build success. By the way, maybe an environment variable or cli argument could do the job to precise the workspace path.

Expected Behavior

Run the nx.js binary from a symbolic linked node_modules directory.

Current Behavior

The workspace is not found because the use of __dirname which does not follow symbol links.

Steps to Reproduce

mkdir ../other-path
mv node_modules ../other-path
ln -s ../other-path/node_modules
./node_modules/.bin/nx print-affected

The command does not return anything because the workspace could not be found.

Context

Please provide any relevant information about your setup:

❯ nx report

>  NX  Report complete - copy this into the issue template

  @nrwl/angular : 9.2.1
  @nrwl/cli : 9.0.4
  @nrwl/cypress : 9.2.1
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 9.2.1
  @nrwl/linter : 9.2.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : 9.2.1
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.0.4
  @nrwl/web : Not Found
  @nrwl/workspace : 9.2.1
  typescript : 3.8.3

Thanks in advance

@brandonroberts brandonroberts added scope: core core nx functionality type: bug labels Apr 16, 2020
@github-actions github-actions bot added the stale label May 29, 2020
@vsavkin vsavkin removed the stale label May 29, 2020
@nrwl nrwl deleted a comment from github-actions bot May 29, 2020
@anton-gorbikov
Copy link

We are having the exact issue. To speed up the build pipelines we wanted to cache docker image with node_modules pre-installed and share it among several CI jobs. And we've faced an issue that nx is not working with symbolic links, because of __dirname usage. __dirname returns the path where the actual node_modules are stored and nx is not able to find a workspace there.

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants