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

[FIX] WIndows binary #671

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

[FIX] WIndows binary #671

wants to merge 11 commits into from

Conversation

dupasj
Copy link

@dupasj dupasj commented Mar 23, 2024

I encountered issues when running the node-jq binary from the package. I discovered that if you don't append .exe to the bin package file path, the binary isn't added/symlinked in the node_module/.bin/ repository, resulting in the binary not being resolved.

In response to this issue, I've added the renamePackageBin function, which forces to assign the full filename as the binary file in the package.json, resolving the problem.

I've executed this function in all OS contexts, which should work, but we can consider guarding it for Windows only (when the filename ends by .exe, for example).

Copy link
Member

@davesnx davesnx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure this works fine in Windows on CI?

package.json Outdated
]
}
}
"name": "node-jq",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you revert this file changes?

package.json Outdated
"url": "https://github.com/sanack/node-jq"
},
"bin": {
"node-jq": "bin/jq.exe"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's rather annoying to add here, since it will break linux-based OS. Please remove this diff

const OUTPUT_DIR = path.join(__dirname, '..', 'bin')
const OUTPUT_FILE = path.join(OUTPUT_DIR, JQ_NAME)

const renamePackageBin = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this function to "makeBinaryWorkInWindows"? and add comments on all things happening here? Replace \ with / and also implement the append of ".exe"?

Copy link
Author

@dupasj dupasj May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I resolved:

  • rename renamePackageBin to makeBinaryWorkInWindows
  • replace / by \ (this was for dev proposes)

@dupasj
Copy link
Author

dupasj commented May 13, 2024

Can we make sure this works fine in Windows on CI?

I do not have access to your CI or I cannot see the CI, can you please me prompt me the error if you have ?

@dupasj
Copy link
Author

dupasj commented May 13, 2024

Hi @davesnx !

After some tests, I found out that when you reinstall the dependency, the binary file is welly symbolinked.

It's look like the binary symbolink are created before the preinstall hooks (so if the file is not already downloaded, the symbolink is ignored.) So I force it by running "npm link ." in the package folder after the file download (take a look at this commit).

Note that I also change the test unit: I had to replace "null" with "undefined" in some places.

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

Successfully merging this pull request may close these issues.

2 participants