1

I am new to Docker, Debezium, Bash, and Kafka. I am attempting to run the Debezium tutorial/example for MSSQL Server on Windows 10 here:

https://github.com/debezium/debezium-examples/blob/master/tutorial/README.md#using-sql-server

I am able to start the topology, per step one. However, when I go to step two and execute the following command:

cat debezium-sqlserver-init/inventory.sql | docker exec -i tutorial_sqlserver_1 bash -c '/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD'

I get the following error:

bash: C:/Program: No such file or directory

I do not have the foggiest idea why it would even drag C:/Program in to this. I do not see it in the command nor do I see it in the *.sql file. Does anyone know why this is happening and what the fix is?

Note 1: I am already in the current directory where this command should be runnable and there are no spaces in the folder/file path

Note 2: I am running the commands in Git Bash


When using set -x to log how the command is run, there's still no C:/Program anywhere in it, as can be seen by the following log:

$ cat debezium-sqlserver-init/inventory.sql | docker exec -i tutorial_sqlserver_1 bash -c '/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD'
+ cat debezium-sqlserver-init/inventory.sql
+ docker exec -i tutorial_sqlserver_1 bash -c '/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD'
bash: C:/Program: No such file or directory
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
J Weezy
  • 3,507
  • 3
  • 32
  • 88
  • 1
    Also smells like inadequate quoting leading to early string-splitting. – Charles Duffy Apr 03 '20 at 20:53
  • I tried adding a single quote to `'debezium-sqlserver-init/inventory.sql'`, but that did not work. – J Weezy Apr 03 '20 at 20:54
  • First off, that command you're running is a UNIX shell command. It's not quoted correctly for Windows. I assume you're in `cmd.exe` or powershell? – Charles Duffy Apr 03 '20 at 20:55
  • I am using Git Bash. Do you know what the Powershell equivalent is? I prefer that. – J Weezy Apr 03 '20 at 20:55
  • If you run `set -x` before the command, what logs does it emit? – Charles Duffy Apr 03 '20 at 20:56
  • Problem might be `C:/Program Files...` -> Bash word splitting -> `"C:/Program" "Files..."`. Not sure the cause though. Maybe `PATH` environment variable? – wjandrea Apr 03 '20 at 20:56
  • @wjandrea, true, but how's that getting into the command? I don't see where... hence requesting `set -x` logs, which will hopefully make it more clear. – Charles Duffy Apr 03 '20 at 20:56
  • @CharlesDuffy Same error: `bash: C:/Program: No such file or directory`. Note: The command I executed was `set -x cat debezium-sqlserver-init/inventory.sql | docker exec -i tutorial_sqlserver_1 bash -c '/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD'` – J Weezy Apr 03 '20 at 20:58
  • 1
    @JWeezy, two separate commands. `set -x` is one command. Run it, press enter, then type the command you want to collect logs for; run `set +x` to turn that logging off later. Subsequent lines will still run (and fail) the same way they did before, but before they do, they'll print a log that explains what it is they're up to. – Charles Duffy Apr 03 '20 at 20:59
  • @Charles Yeah i'm not sure. Maybe it's an environment variable related to Bash looking up `docker`. – wjandrea Apr 03 '20 at 21:00
  • @CharlesDuffy I have updated my question with the log output. Note: I replaced the path data with ellipses for brevity. – J Weezy Apr 03 '20 at 21:02
  • Unfortunately, the log you printed starts *after* the error. I need what happens *before* the error. Everything in that log is the shell just getting ready to print your prompt (looks like you've got a bunch of fancy git-integration logic enabled in your shell). – Charles Duffy Apr 03 '20 at 21:04
  • @CharlesDuffy I closed Git Bash; opened a new instance of Git Bash; `set -x`; CD'd into the directory into question; and ran the command in question. I have attached the revised output. – J Weezy Apr 03 '20 at 21:08
  • Surely when you did the cd into the directory, there was an xtrace log from that `cd` command itself? I've reloaded the page, and still see nothing above the `bash: C:/Program: No such file or directory` – Charles Duffy Apr 03 '20 at 21:15
  • (you might consider turning off `__git_ps1`, btw, just to not have the log clutter). – Charles Duffy Apr 03 '20 at 21:17
  • Updated full output. Also, how do I turn of `__git_ps1`? – J Weezy Apr 03 '20 at 21:19
  • 1
    Okay -- the two lines I asked for all that logging in order to find are `+ cat debezium-sqlserver-init/inventory.sql` and `+ docker exec -i tutorial_sqlserver_1 bash -c '/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD'` -- letting us know that the argument list gets changed *after* the shell starts trying to execute `docker`. To track down what happens past that point we'd change `bash -c` to `bash -xc`, but since we've got an answer, that's no longer needed. – Charles Duffy Apr 04 '20 at 00:48
  • 1
    ...as for how you turn of `__git_ps1`, that depends on how you configured it in the first place; it could be called from your `BASH_COMMAND` variable, or it could be part of the `PS1` variable that forms your prompt directly. Those aren't the only possible hooks, but they're certainly the most likely ones. – Charles Duffy Apr 04 '20 at 00:51

1 Answers1

8

I had a similar problem yesterday, the solution was adding a backslash before the absolute path, like :

cat debezium-sqlserver-init/inventory.sql | docker exec -i tutorial_sqlserver_1 bash -c '\/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD'

\/opt/mssql-tools/bin/sqlcmd prevents conversion to Windows path.

Philippe
  • 20,025
  • 2
  • 23
  • 32
  • 1
    Ahh! To get this logged, we would have wanted `bash -xc '...` – Charles Duffy Apr 03 '20 at 21:16
  • @Philippe Great catch. I am assuming that you ran through the entire tutorial. Can you please post the commands that you ran in order to complete the tutorial? It might be beneficial for anyone who sees this in the future. – J Weezy Apr 03 '20 at 21:37