-
Notifications
You must be signed in to change notification settings - Fork 215
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(xsnap): Accommodate spaces in installation path #10082
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
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.
it's a little surprising that we didn't get bit by this sooner
@@ -21,7 +22,7 @@ const avaHandler = `./avaHandler.cjs`; | |||
|
|||
/** @type { (ref: string, readFile: typeof import('fs').promises.readFile ) => Promise<string> } */ | |||
const asset = (ref, readFile) => | |||
readFile(new URL(ref, import.meta.url).pathname, 'utf8'); | |||
readFile(fileURLToPath(new URL(ref, import.meta.url)), 'utf8'); |
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.
asset()
is about reading stuff out of the package. I wonder about using the node:module
API here.
After thinking it over, I suppose it's more of a change than is necessary to fix this.
But I'll leave my thinking-out-loud here for comparison...
readFile(fileURLToPath(new URL(ref, import.meta.url)), 'utf8'); | |
readFile(nodeRequire.resolve(ref), 'utf8'); |
presuming:
import { createRequire } from 'node:module';
const nodeRequire = createRequire(import.meta.url);
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.
It occurred to me, and would be useful especially for reaching for assets in other packages.
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 like it!
Not a blocker, of course. I suppose it'll come up again when we fully expunge .pathname
1768df2
to
e1b2a28
Compare
@@ -21,7 +22,7 @@ const avaHandler = `./avaHandler.cjs`; | |||
|
|||
/** @type { (ref: string, readFile: typeof import('fs').promises.readFile ) => Promise<string> } */ | |||
const asset = (ref, readFile) => | |||
readFile(new URL(ref, import.meta.url).pathname, 'utf8'); | |||
readFile(fileURLToPath(new URL(ref, import.meta.url)), 'utf8'); |
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 like it!
Not a blocker, of course. I suppose it'll come up again when we fully expunge .pathname
Description
When installed on a Mac via npm in nvm, the path to the xsnap binary inevitably includes a space as in
Application Support
. The patternnew URL(location).pathname
does not account for URL encoded spaces in the input URL, as will occur based onimport.meta.url
. This pivots xsnap to useurl.fileURLToPath
instead which does take these into account as well as Windows drive letters.Security Considerations
None.
Scaling Considerations
None.
Documentation Considerations
None.
Testing Considerations
I created a git worktree named
agoric sdk
for the development of this branch. The xsnap tests failed under that directory name before this change, and worked afterward.Upgrade Considerations
None.