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

Please implement PACKAGE_JSON_NODE_MODULES_BIN_PATH as a fallback if the package manager path for an exeuctable doesn't exist #21

Open
cryptomilk opened this issue Feb 15, 2025 · 2 comments

Comments

@cryptomilk
Copy link

If you choose to install the node_modules in an absolute path like /usr/src/node_modules it looks like all current package manager don't support this fully.

See yarnpkg/yarn#7519 or pnpm/pnpm#9113

The best would be if the package_json.manager.native_exec_command() would check if the executable exists. In case it doesn't exist fall back to an environment variable like PACKAGE_JSON_NODE_MODULES_BIN_PATH and check if the executable exists in this path else throw and error.

shakapacker up to version 7.x had support for SHAKAPACKER_NODE_MODULES_BIN_PATH which worked around those broken package managers. However shakapacker fully relies on package_json now. I think the workaround should be implemented in package_json.

Thanks!

@cryptomilk
Copy link
Author

See also shakacode/shakapacker#550

@G-Rath
Copy link
Collaborator

G-Rath commented Feb 16, 2025

I'm not sure if this is something that package_json should be responsible for, as it's intended to be an abstraction over interacting with package.json regardless of package manager, whereas this is more generally "running a command" and potentially a bug in the package managers themselves.

More practically, my concern is that this increases the complexity - we either need to somehow figure out that the error was because the command didn't exist, or otherwise just assume that that's why it errored (which I think overall would be pretty unsafe to do), then we've got to check if the executable exists in the fallback path, which I believe on Linux is done with which but on Windows its with where so now we have to act differently depending on OS...

Overall this feels like something that could be better handled in Shakapacker, even at least just to start - given that, I'm going to post the rest of my thoughts on your Shakapacker issue, and we can continue talking there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants