-
Notifications
You must be signed in to change notification settings - Fork 62
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
replaces path to .asar.unpacked if cmd includes .asar/node_modules #155
Conversation
@thisconnect I'm not sure if I understand all the implications here. If |
This PR checks if the path to the ipfs binary points to inside an asar archive and changes the path to asar.unpacked. It tests for With this change It successfully bundle MyApp into an asar archive and am able to start the ipfsd-ctl deamon, that is in app.asar.unpacked. At this point I think it should be done in the findIpfsExecutable function https://github.com/thisconnect/js-ipfsd-ctl/blob/4453ea7caed94a00cac54d57c1e60d1e6420c1d7/src/node.js#L19 related docs https://electron.atom.io/docs/tutorial/application-packaging/#executing-binaries-inside-asar-archive An other solution would be to be able to configure the path to the ipfs binary. |
The configuration could be done on as api or environment variable. As a ipfsd-ctl consumer I want to just use the api and not write my code differently for a packaging detail. I am unsure if configuring the path with an env variable is possible and a good idea :/ |
Got it. I'm afraid I haven't used enough electron to know the full breadth of issues, but this PR doesn't seem to break our existing use cases so I'm fine trying it out :) Could you add documentation of the issue and how to circumvent it with the packaging command you mention here so that others can try it too? @kyledrake, you've been hacking on electron and going through the same issues, mind sharing your thoughts here? |
Please do NOT merge this yet, it may not work on windows, due to forward slash. Not sure if that works with Node 4.x / npm 2.x when modules are not deduped. I have not tried edit: moved howto to PR description |
Ok tested for windows
Please review https://github.com/ipfs/js-ipfsd-ctl/pull/155/files |
@thisconnect is this ready for review and merge? |
@diasdavid yes please. also please have a look at this line, https://github.com/ipfs/js-ipfsd-ctl/pull/155/files#diff-6ff379484cbabad48301d485db111c08R32 that should have been a different PR. in the meantime the power port of my windows laptop melted. Do you use appveyor for windows CI? |
@thisconnect just enabled appveyor for this repo. Could you add the config file (Tutorial, Great example) https://ci.appveyor.com/project/diasdavid/js-ipfsd-ctl-a9ywu |
Also, just added you to the JS team. You can now create branches on the main repo and PR directly from them. This helps collaboration between multiple people https://github.com/orgs/ipfs/teams/javascript-team/members 🌟 |
Thanks @diasdavid I'll find time over the weekend and will create a branch for appveyor. |
Ok, I'll be more tranquil to merge this PR when I see the tests passing in Windows and in Linux CI :) |
…d (tested macos and win32)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thisconnect thank you for keeping on pushing on this front :) Can't wait to merge this PR!
// electron-packager ./ --asar.unpackDir=node_modules/go-ipfs-dep | ||
if (appRoot.includes(`.asar${path.sep}`)) { | ||
appRoot = appRoot.replace(`.asar${path.sep}`, `.asar.unpacked${path.sep}`) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add this to the README too? It is fine to leave it here, but I want to make sure it this note is searchable and linkable to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There is a failing test on windows https://ci.appveyor.com/project/diasdavid/js-ipfsd-ctl/build/21/job/ohabcvtp3jtlsgoa#L1610 , |
@thisconnect ipfs-inactive/js-ipfs-http-client#408 shouldn't be an issue of this module specifically. Is there another test you can add to check that the module works? |
@diasdavid I have never built electron within CI, it should be possible but might take a long time. Not sure if it is worth right now. I tried to add some info in the readme and a minimal example in examples/electron-asar, please have a look |
The "checks response of ipfs.util.addFromFs for windows" now tests too much. Do you prefer A) the deep equal that should cover everything about the response https://github.com/thisconnect/js-ipfsd-ctl/blob/46c422ebf1f5b11acecf81da74a553fbab4093d5/test/index.spec.js#L394-L406 B) or remove it and keep the rest https://github.com/thisconnect/js-ipfsd-ctl/blob/46c422ebf1f5b11acecf81da74a553fbab4093d5/test/index.spec.js#L408-L418 C) or keep it as it was before EDIT: other than that I think it should be ready, unfortunately my windows laptop's power supply burned so I can't test on windows. |
@thisconnect given that addFromFs has issues in Windows, I don't believe it to be a good test case to have. Update: Check process.env and if Windows skip that test with a comment describing that is waiting on the fix for js-ipfs-api |
@@ -390,10 +390,32 @@ describe('daemons', () => { | |||
if (err) throw err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see: #155 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an example: https://github.com/ipfs/npm-go-ipfs-dep/blob/master/src/index.js#L47-L60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is a temporary skip, is it ok if I just os.platform() === 'win32'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get https://github.com/ipfs/npm-go-ipfs-dep/blob/master/src/index.js#L47-L60 sorry!! :( it also depends on another module (go-platform) and file https://github.com/ipfs/npm-go-ipfs-dep/blob/master/src/check-support.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woot! Will just wait on CI!
Not sure what the last one is all about https://ci.appveyor.com/project/diasdavid/js-ipfsd-ctl/build/24/job/t4r5euk57pms9d20#L1610 |
Seems like a go-ipfs thing, @Kubuxu ? |
https://github.com/thisconnect/js-ipfsd-ctl/blob/f3e49d54ecb143d130812dfc07ebd0788ae5aa72/test/index.spec.js#L438 checks for a repo.lock file in index.spec.js , something before did not close correctly? |
Nothing changed in go-ipfs that could cause it. How does shutting down work? Does it wait for go-ipfs to shutdown? Is it station timeout or does it poll the process? |
It is the first time we are enabling Windows testing in this module, so really anything is worth ;) Sounds like that go-ipfs never really deleted the lock file but in windows (such as OS X or Linux) it just gives 0 frambroises and continues. Here, since we check for it, we actually saw it is there. @thisconnect let's skip that check if in Windows as well :) This isn't a real issue. Thanks for jumping in too @Kubuxu :) |
It might be Windows, Windows is a bit neglected so it is possible that this is an issue. |
test/index.spec.js
Outdated
if (fs.existsSync(path.join(dir, 'api'))) { | ||
cb(new Error('api file not removed')) | ||
} | ||
cb() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean to skip the whole test, just to skip the assertion for repo.lock
test/index.spec.js
Outdated
cb(new Error('api file not removed')) | ||
// skip on windows | ||
// https://github.com/ipfs/js-ipfsd-ctl/pull/155#issuecomment-326983530 | ||
if (isWindows) it.skip('start and stop') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add curly {}
there was travis fail |
api file assert has to go too https://ci.appveyor.com/project/diasdavid/js-ipfsd-ctl/build/26/job/gubdael6q0fl8fxu#L1685 |
} | ||
if (fs.existsSync(path.join(dir, 'api'))) { | ||
cb(new Error('api file not removed')) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
js-ipfsd-ctl will not work inside an asar container, see #94.
A possible solution is to exclude the ipfs binary from asar, with the unpackDir option
(EDITED: changed
go-ipfs-dep/**
togo-ipfs-dep
)on MacOS: this will package everything expect go-ipfs-dep into
<appname>.asar
and put go-ipfs-dep into
<appname>.asar.unpacked/node_modules/go-ipfs-dep
This change request adds a check if
.asar/
is part of the path and changes it to.asar.unpacked/
Edit:
How to test this change
Assuming you have a project using ipfsd-ctl, electron and electron-packager.
Install https://github.com/thisconnect/js-ipfsd-ctl/tree/asar-unpacked
build electron with
--asar.unpackDir=node_modules/go-ipfs-dep
Test if your app works and if everything (but go-ipfs-dep) is bundled in an .asar file