mssql-cli icon indicating copy to clipboard operation
mssql-cli copied to clipboard

Modify mssql-cli bash wrapper to look for and prefer python3

Open JPvRiel opened this issue 4 years ago • 3 comments

On Ubuntu 20.04, the following install via pip does not work:

pip3 install --user mssqlcli

There are instructions to use a deb package for 18.04, but that's not an option. Related issues: #505, #482

In the bash wrapper to run this, I noticed python, and not python3, is assumed as the executable at https://github.com/dbcli/mssql-cli/blob/53a7a8a35193b1d2c8c8d85a2cdd7a4c3e3e7409/mssql-cli#L16

Some distributions (at least Debian/Ubuntu) facilitate the transition from python2 to python3 by having python point to python2 and python3 be a separate binary.

Instead of:

python -m mssqlcli.main "$@"

The following way of using command to check and match might help:

python_exe=$(command -v python3 || command -v python)
$python_exe -m mssqlcli.main "$@"

Then absolute path should be nicely resolved, e.g. /usr/bin/python3 for systems that have a binary found in the PATH.

JPvRiel avatar May 24 '21 15:05 JPvRiel

An install on macOS has the same problem, with the additional problem that it apparently assumes bash is the user's shell, without checking one way or the other.

posguy99 avatar Jun 19 '21 16:06 posguy99

I've encountered this issue as well and just opened a ticket (https://github.com/dbcli/mssql-cli/issues/523) to elaborate on the problem further, specifically for my setup.

ethan-fox-capsule avatar Jun 29 '21 17:06 ethan-fox-capsule

I have encountered the same thing - the /usr/local/bin/mssql-cli script hard-assumes "python" rather than looking for python3. I suppose another workaround might be creating a symbolic link so that the command "python" runs "python3".

The workarounds above worked for me.

joshuaclausen avatar Feb 25 '22 18:02 joshuaclausen