redwood icon indicating copy to clipboard operation
redwood copied to clipboard

[Bug]: Can't use baremetal deploy from a Windows machine to a *nix machine

Open cannikin opened this issue 1 year ago • 3 comments

What's not working?

Baremetal uses path.join() when building up the deploy path, but path.join() is running on the deploy machine, not the host machine: https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/commands/deploy/baremetal.js#L212

So if you're trying to deploy from Windows then it will create the path with backslashes, even though you may be deploying to a *nix machine which uses forward slashes.

How do we reproduce the bug?

Try to use Baremetal deploy from a Windows machine to a *nix machine:

image

Note that the path contains backslahes. :(

What's your environment? (If it applies)

No response

Are you interested in working on this?

  • [ ] I'm interested in working on this

cannikin avatar Aug 04 '22 17:08 cannikin

I can think of two possible solutions:

  1. Instead of using path.join() just hardcode forward slashes (or force path.join() to use them, which would be my preference) and make it a requirement of Baremetal deploy that you can only deploy to *nix systems
  2. Somehow detect the OS that you're deploying to and determine the slash direction on the fly. However, I'm not sure that this deployment would even work going to a Windows machine...is SSH even widely supported for connecting to Windows machines?

I'm leaning towards (1) since I don't know that (2) is even possible, or if anyone would ever need that anyway (do people serve Node apps from Windows machines??)

cannikin avatar Aug 04 '22 17:08 cannikin

I lean toward the former as well, and a very good point about node apps being deployed to windows machines. Narrowing scope seems appropriate.

russell-davis avatar Aug 04 '22 17:08 russell-davis

We have a third option! @pantheredeye suggested in Discord that we default to forward slashes always, but make a --windows flag available that will override and use backslahes. So if you really want to deploy to a Windows machine you still can. It remains to be seen if you can actually serve the app from Windows, however. :)

I found a dedicated npm package just for converting paths to forward slashes always: https://www.npmjs.com/package/slash

cannikin avatar Aug 04 '22 17:08 cannikin