OP-Engineering / op-sqlite

Fastest SQLite library for react-native by @ospfranco
MIT License
556 stars 38 forks source link

pod install fails when using pnpm #172

Open joprice opened 6 days ago

joprice commented 6 days ago

When trying to use this project with pnpm, an error like the one below is raised when running pod install. It seems that the relative path used to find the project's root directory will not work with package managers that use symlinks with a global store. Perhaps an env var could be used similar to what's done here https://github.com/pnpm/pnpm/blob/main/workspace/find-workspace-dir/src/index.ts, or simply rely on the current working directory (although this would then assume that you're running the command in the parent directory).

Couldn't install Pods. Updating the Pods project and trying again...
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file:
[!] Invalid `op-sqlite.podspec` file: No such file or directory @ rb_sysopen - <redacted_path>/../../../package.json
ospfranco commented 6 days ago

Does this happen with other packages? I don't think metro supports symlinks anyways. In any case, feel free to submit a PR, no time to investigate this myself

joprice commented 5 days ago

It looks like it was added a while back https://reactnative.dev/blog/2023/06/21/0.72-metro-package-exports-symlinks. But, without configuring that, I had been using pnpm with a react native project for a few weeks until installing this project, so it seems like the unstable flag might not even be needed anymore.

I was wondering how other projects do this, but so far only thought of codegen. Turns out it uses the app_path parameter https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L67 to find the package.json config. That pattern requires modifying podfile to pass the arg, so inconvenient. I'm going to poke around at other projects to see if anyone's come up with a convenient patter that works across bundlers. Otherwise, I'll try using an optional env var and falling back to the relative path.

ospfranco commented 5 days ago

Oh, I just got it, you mean reading the package.json from the podspec! Ah yeah, op-sqlite is quite unique in that regard. Let me know if you find anything.