Closed hjalmarhoglund closed 6 months ago
@hjalmarhoglund Thanks for reporting this. I'm going to tag in another team member who specializes in deployment and will get back o you!
Hey @hjalmarhoglund, would you mind trying out v7.6.1 and confirm that the fix works?
Hey @Josh-Walker-GM! Sure, I've upgraded and tested deploying. I believe another error has been introduced. This time, the error affects both the verbose and the none-verbose baremetal deploys.
Running,
yarn rw deploy baremetal production --verbose
gives the output
...
[STARTED] Cloning `main` branch...
SshExecutor::exec running command `gitclone --branch=main --depth=1 git@github.com:hjalmarhoglund/myapp.git 20240522150326` in /var/www/myapp
[FAILED] Error while running command `gitclone --branch=main --depth=1 git@github.com:hjalmarhoglund/myapp.git 20240522150326` in /var/www/myapp
[FAILED] bash: line 1: gitclone: command not found
Running,
yarn rw deploy baremetal production
gives the output
Error while running command `gitclone --branch=main --depth=1 git@github.com:hjalmarhoglund/myapp.git 20240522150713` in /var/www/myapp
bash: line 1: gitclone: command not found
...
The problem is that git clone [...]
becomes gitclone [...]
.
Looking at the new code for SshExecutor.js
we find on lines 13 and 14,
const argsString = args?.join(' ') || ''
const sshCommand = command + argsString
which does not correctly set a space between the command and the first arg.
I think this could be solved by changing line 13 to:
const argsString = args ? ' ' + args.join(' ') : ''
Testing this in a local Node.js v20.11.1
session:
function testFix(command, args) {
const argsString = args ? ' ' + args.join(' ') : ''
const sshCommand = command + argsString
// See what we end up with
console.log(sshCommand)
}
const command = 'git'
const args1 = ['clone', '--branch=main']
const args2 = undefined
// Now running the proposed expression of argsString towards both args1 and args2
testFix(command, args1)
testFix(command, args2)
Gives the output
git clone --branch=main
git
I try implementing my fix into node_modules/@redwoodjs/cli/dist/commands/deploy/baremetal/SshExecutor.js
and run the deploy scripts, both verbose and non-verbose. For me, everything works.
...
async exec(path, command, args) {
//const argsString = args?.join(" ") || "";
const argsString = args ? ' ' + args.join(' ') : ''
const sshCommand = command + argsString;
...
Hope this is of help, and thank you for getting to this as quickly as you did! Let me know if you want me to test anything again.
Thanks for testing this so quickly! I agree we've messed up and introduced an even worse error! I'll get a fix and patch out again for this today
Okay v7.6.2 is out with the further fix. Hopefully we didn't break it even more haha!
Fantastic! I've tested deploying on v7.6.2. Both verbose and non-verbose works like a charm!
What's not working?
When deploying to baremetal and setting the verbose flag,
all goes well until the last step, the cleanup step. The following output is produced:
Notably, the deploy doesn't actually fail. The app is re-deployed and everything works. If you deploy without the verbose flag,
no error occurs.
I believe that the error comes from
packages/cli/src/commands/deploy/baremetal/SshExecutor.js
, where on lines 21 and 31 no check ifargs
is undefined is done. I believe this is the case since the error only occurs when using the verbose flag.How do we reproduce the bug?
Run
yarn rw deploy baremetal production --verbose
towards your baremetal server.What's your environment? (If it applies)
Are you interested in working on this?