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] Does not work with pnpm #277

Open
mczapkowicz opened this issue Dec 1, 2022 · 12 comments
Open

[BUG] Does not work with pnpm #277

mczapkowicz opened this issue Dec 1, 2022 · 12 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mczapkowicz
Copy link

Describe the bug
When using pnpm as a package manager reassure binary cannot be found.
After running command pnpm reassure i get:

 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  not found: reassure

I noticed that reassure binary is missing in the node_modules/.bin folder.

To Reproduce
Steps to reproduce the behavior:

  1. Create react project with create-react-app
  2. Add reassure to the project using pnpm add reassure -D
  3. run pnpm reassure
@mczapkowicz mczapkowicz added the bug Something isn't working label Dec 1, 2022
@mdjastrzebski
Copy link
Member

@mczapkowicz you are right, we did not test pnmp compatibility. That the issue you are facing should be relatively easy to work around: you can set TEST_RUNNER_PATH env variable to proper reassure CLI path.

@mczapkowicz
Copy link
Author

Thanks for the answer @mdjastrzebski . Yes, I tried that already by running fallowing command:
TEST_RUNNER_PATH=node_modules/reassure/node_modules/.bin/reassure pnpm reassure
but the error still occurs.

@mdjastrzebski
Copy link
Member

mdjastrzebski commented Dec 1, 2022

Is that the same error or different one? Pls paste exact error details.

@mczapkowicz
Copy link
Author

Yes, the error is exactly the same:
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  not found: reassure

@mdjastrzebski
Copy link
Member

I think we've confusing two things here. One is TEST_RUNNER_PATH which should have path to test runner, e.g. Jest
While you issue seems to be about executing Reassure CLI itself. Since this is a simple node executable you should be able to run it using:

  • node node_modules/reassure/node_modules/.bin/reassure
  • or: node node_modules/.bin/reassure
  • or ./node_modules/reassure/node_modules/.bin/reassure

@mczapkowicz
Copy link
Author

  • TEST_RUNNER_PATH=node_modules/.bin/jest node node_modules/reassure/node_modules/.bin/reassure

gives me:

 /Users/user/Desktop/test-project/node_modules/.pnpm/reassure@0.6.0_react@18.2.0/node_modules/reassure/node_modules/.bin/reassure:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47
  • node node_modules/.bin/reassure, gives:
    Cannot find module '/Users/user/Desktop/test-project/node_modules/.bin/reassure
    which makes sense because, like I said there is no reassure in node_modules/.bin folder
  • ./node_modules/reassure/node_modules/.bin/reassure gives
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '/Users/user/Desktop/test-project/@callstack+reassure-cli@0.5.0/node_modules/@callstack/reassure-cli/lib/commonjs/bin.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

@mdjastrzebski
Copy link
Member

@mczapkowicz:

  • what OS are you using? Another used reported the first error (=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")) for Windows env.
  • could you try to use it with yarn or npm? I wonder if this is more OS-specific of package manager specific?

@mczapkowicz
Copy link
Author

mczapkowicz commented Dec 1, 2022

I'm using macOS. Everything works fine with yarn and npm so I belive this is package manager specific.
This may be caused by the fact that contrary to npm and yarn module hoisting, pnpm uses non-flat node_modules structure.
So with npm and yarn node_modules inside reassure are getting hoisted including .bin - with pnpm they are not.

@mdjastrzebski
Copy link
Member

mdjastrzebski commented Dec 2, 2022

@mczapkowicz do you have some available time and would like to bring PNMP support to Reassure? 😀

The issue here seems to be specific to how PNPM works rather than the actual Reassure code.

@mczapkowicz
Copy link
Author

I will take a look at this.

@Zenor27
Copy link

Zenor27 commented Jan 25, 2023

Same problem here using on macOS, seems related to pnpm indeed.

@gdagundaridze
Copy link

gdagundaridze commented Mar 13, 2023

For anyone that may benefit, i was able to make this work with pnpm in a slightly ugly but temporarily acceptable way like this:
TEST_RUNNER_PATH=node_modules/jest/bin/jest ../../node_modules/.pnpm/reassure@0.7.2_react@18.2.0/node_modules/reassure/node_modules/.bin/reassure

Note that this exact solution may not work for everyone as it relies on relative path. Takeway here is that for test runner we rely on js file instead of binary and as reassure binary we seek the root installation of reassure instead of relying on symlinks, in which case relative paths inside that binary work fine

Will try to submit a PR so that hacking like this is not required

@mdjastrzebski mdjastrzebski added the help wanted Extra attention is needed label Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants