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

Building ssh2 without Python installed #1297

Closed
SaharAvr opened this issue May 14, 2023 · 7 comments
Closed

Building ssh2 without Python installed #1297

SaharAvr opened this issue May 14, 2023 · 7 comments
Labels

Comments

@SaharAvr
Copy link

I believe there are some native modules that require Python to be installed in order to build ssh2. Is there another version or some workaround to build it without having Python installed (unfortunately this is a constraint)?

@mscdex
Copy link
Owner

mscdex commented May 14, 2023

That is not correct. All compilable addons used by ssh2 are optional and the module will work fine without them.

Also just as a heads up, all node.js compilable addons use Python (indirectly via node-gyp) as part of the standard build system.

@SaharAvr
Copy link
Author

@mscdex Thanks for the quick reply. Could you try to run npm i ssh2 on an environment without Python? I myself receive errors from PythonFinder

@mscdex
Copy link
Owner

mscdex commented May 14, 2023

Does npm ls --depth=0 where you ran npm install ssh2 show ssh2 in the displayed list? If so, then there is no problem and the module is installed.

@SaharAvr
Copy link
Author

@mscdex Thank you for your response and clarification. I can confirm that ssh2 is displayed in the list when I run npm ls --depth=0, and the module works as expected.

However, my concern is about the errors displayed on the screen during the installation of my package, which has ssh2 as a dependency. The errors might confuse users or make them think that something went wrong during the installation process. Is there any way to suppress these errors or provide a better user experience during the installation of ssh2 without having Python installed?

I understand that Python is required for building native modules via node-gyp, but I'm looking for a way to improve the installation experience for users who don't have Python installed. Any suggestions or workarounds would be greatly appreciated.

@mscdex
Copy link
Owner

mscdex commented May 15, 2023

Unfortunately it's not that easy. The optionalDependencies is handled by npm or whatever package manager people use, so there isn't really anything a package author can do about that.

As far as the bundled optional addon goes, we attempt to build that explicitly at package installation time, but it's tricky because the only way to remedy the error output issue would be to use a command line flag to optionally show the output (in case people want to know why it wasn't installing properly) and package managers haven't really standardized on if/how custom command line flags are passed to package scripts. I believe npm still passes them as individual environment variables or something, but IIRC other package managers don't provide them at all.

I suppose another solution could be setting an environment variable beforehand, but I haven't looked to see if those are passed on to install scripts either.

@SaharAvr
Copy link
Author

@mscdex Thank you for your detailed response and explanation of the challenges involved in suppressing the error output during the installation process.

As a workaround, I ended up creating a custom package called ssh2-custom, which includes the pre-built native modules for the target platforms. This way, users can install the custom package without encountering errors related to the building of native modules. I understand this might not be the most elegant solution, but it seems to work for my specific use case.

Here's the link to the new ssh2-custom GitHub repository: https://github.com/SaharAvr/ssh2-custom

I appreciate your help and guidance on this issue. If you have any feedback or suggestions for the custom package, please feel free to share them with me.

@mscdex
Copy link
Owner

mscdex commented May 15, 2023

Unfortunately providing pre-built addons is not really feasible at this time for a variety of reasons. I even previously created my own set of tools while exploring the subject because I found the existing solutions lacking.

Basically the issue is that support for pre-built addons needs to be standardized but package manager devs can't seem to come together to do so (e.g. this npm RFC issue and this yarn issue on the subject). Last year I outlined what's really needed to provide a good solution for pre-built binaries that unfortunately seems to have fallen on deaf ears. You can accomplish some of this with a postinstall package script, but not if package scripts have been disabled by the user for example (which is a whole other topic).

@mscdex mscdex closed this as completed May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants