reassure icon indicating copy to clipboard operation
reassure copied to clipboard

[BUG] Does not work with pnpm

Open mczapkowicz opened this issue 3 years ago • 13 comments

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 avatar Dec 01 '22 09:12 mczapkowicz

@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.

mdjastrzebski avatar Dec 01 '22 10:12 mdjastrzebski

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.

mczapkowicz avatar Dec 01 '22 13:12 mczapkowicz

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

mdjastrzebski avatar Dec 01 '22 13:12 mdjastrzebski

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

mczapkowicz avatar Dec 01 '22 13:12 mczapkowicz

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

mdjastrzebski avatar Dec 01 '22 14:12 mdjastrzebski

  • 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/[email protected][email protected]/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/@[email protected]/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: []
}

mczapkowicz avatar Dec 01 '22 14:12 mczapkowicz

@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?

mdjastrzebski avatar Dec 01 '22 14:12 mdjastrzebski

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.

mczapkowicz avatar Dec 01 '22 15:12 mczapkowicz

@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.

mdjastrzebski avatar Dec 02 '22 13:12 mdjastrzebski

I will take a look at this.

mczapkowicz avatar Dec 05 '22 10:12 mczapkowicz

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

Zenor27 avatar Jan 25 '23 16:01 Zenor27

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/[email protected][email protected]/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

gdagundaridze avatar Mar 13 '23 11:03 gdagundaridze

It seems the issue has been resolved. I successfully installed and ran Reassure in pnpm + Vite + ts-jest and pnpm + CRA + Vite environments, and it worked perfectly 👌

Can someone involved confirm this?

V3RON avatar Aug 07 '24 15:08 V3RON