bash: /usr/bin/apt-get: cannot execute binary file: Exec format error - visual-studio-code

I'm having a few issues. I'm using Kali Linux. In the terminal, I attempted to do
apt-get update but I'm getting this message back,
'bash: /usr/bin/apt-get: cannot execute binary file: Exec format
error'
It started having this issue when I attempted to install Visual Studio Code via terminal command dpkg -i code_1.41.1-1576681836_amd64.deb. Although the vscode icon shows up in 'Accessories', once I try to open the program, it doesn't open. So I attempted to do the apt-get update just in case something was being missed. Any help would be greatly appreciated.

Related

How to open Visual Studio Code from the command line on RHEL?

I would like to open VSCode from my RHEL terminal using the code command but when I try to type Shell Command: Install 'code' command in PATH directly in VSCode Command Palette, it indicates that No matching command is found. Is there a way to configure $PATH directly via the command line to make code work?
Finally what worked for me was to run the following commands :
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
dnf check-update
sudo dnf install code

libxkbcommon.so.0: no version information available after installing VSCode update

I am using Ubuntu 14.04 LTS. After updating VSCode to v.1.53.0 I am getting following message on opening VSCode:
/usr/share/code/bin/../code: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by /usr/share/code/bin/../code)
On giving command code --verbose I get following logs: logs
I cannot update current Ubuntu version due to limited admin rights.
If you run code --verbose you will see real problem:
[main 2021-04-16T11:44:45.671Z] Main->SharedProcess#connect
/usr/share/code/code --verbose --no-sandbox: relocation error: /usr/share/code/resources/app/node_modules.asar.unpacked/spdlog/build/Release/spdlog.node: symbol _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
It can't find symbol basic_string::compare
echo _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc | demangle
So to run visual studio code on Ubuntu 14.04 LTS
You just need to copy libstdc++.so.6.0.28 and libstdc++.so.6
to /usr/share/code from ubuntu 20.04 LTS
You can get libstdc++.so.6.0.28 (md5=0e7d34a60136c0cd150917ed099980f2) for example from this deb file
Here simple script to do it for you
#!/bin/sh
wget https://mirrors.wikimedia.org/ubuntu/ubuntu/pool/main/g/gcc-10/libstdc%2B%2B6_10.2.0-5ubuntu1~20.04_amd64.deb
dpkg-deb -R libstdc++6_10.2.0-5ubuntu1~20.04_amd64.deb .
sudo cp -P usr/lib/x86_64-linux-gnu/* /usr/share/code/
file version changed in wikimedia.org so new script:
#!/bin/sh
wget https://mirrors.wikimedia.org/ubuntu/ubuntu/pool/main/g/gcc-10/libstdc%2B%2B6_10.3.0-1ubuntu1~20.04_amd64.deb --no-check-certificate
dpkg-deb -R libstdc++6_10.3.0-1ubuntu1~20.04_amd64.deb .
sudo cp -P usr/lib/x86_64-linux-gnu/* /usr/share/code/
md5sum of new libstdc++.so.6.0.28 604ec2999aeb3aadd0e96103fd4b5e5d
Then just type code
ps: very good font for vscode JetBrains Mono
I downgraded my VSCode to lower version. Apparently you can access previous versions of VSCode from it's website but the link's font was too big form me to see.
Still if someone does come across any other alternative please share.
Leaving this here for others.

Visual Studio Code, autopep8 doesn't run

On Windows 10.
I did this:
pip install autopep8
and in vscode user settings I have
"python.linting.pep8Enabled": true,
"python.formatting.provider": "autopep8",
When I run format document, or explicitly invoke autopep8 from the command pallette, the error is:
Error: Command failed: autopep8 c:\tca-backend\lambdas\utilities\NetMenuAPIUtil.py
'autopep8' is not recognized as an internal or external command,
operable program or batch file.
Clearly, vsc wants to invoke autopep8.exe but there is no exe. Just py. So I created a autopep8.bat which works when I test from the command line, but when run from vsc, it inserts the content of the batch file into the top of the document. (Yes, that's as strange as it sounds.)
All other Python-related operations work ok, including the ESLint extension.
VS code Python extension supports source code formatting using either autopep8 (the default), black, or yapf so you don't need to install python formatting tools by yourself.
The way I use formatting is to set a shortcut in vs code.
Go to File -> Preferences -> Keyboard Shortcuts, then search format. Set the shortcut as ctrl + shift + p which is the same as the shortcut of autopep8 or you can set any combination you prefer.
Click the shortcuts in your .py files then you will get the formatted code.
Ref: https://code.visualstudio.com/docs/python/editing
Since you are using VSCode on Windows, please click on the Terminal Section and type
pip install pep8
This will start installing pep8.
for me, the autopep8 doc installation isn't enough, still seeing this error, I had to follow this https://pip.pypa.io/en/latest/user_guide/#user-installs. it works like a charm.
I'm on windows so I used this:
py -m pip install –-user autopep8
You need to add this as a PATH under System Environment Variables:
c:\users\<username>\appdata\roaming\python\python39\site-packages
Then close and restart VS Code. Type autopep8 at a terminal prompt and you should see this:
C:\Foobar>autopep8
usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename] [--ignore-local-config] [-r] [-j n] [-p n] [-a] [--experimental] [--exclude globs] [--list-fixes] [--ignore errors] [--select errors]
[--max-line-length n] [--line-range line line] [--hang-closing] [--exit-code]
[files ...]
autopep8: error: incorrect number of arguments
I encountered an error message while trying to do same and below was what I did (in my terminal):
Install or upgrade pep8:
pip install --upgrade autopep8
Navigate to the folder/directory where the file you need formatted is, then use the following command:
autopep8 --in-place file_name
There you have it!
I encountered this same error running WSL: Ubuntu-20.04, well this was my solution:
$ pip --version
This will make you verify that you have python3 pip installed correctly in your distribution, if that's not the case, it will pop up an error:
Command 'pip' not found, but can be installed with:
apt install python3-pip
Just run the indicated command to installed it and then after that, run:
$ python3 -m pip install autopep8
Now everything should be working as it should, including the formatting autpep8.

Installing Snoopy-ng

I had a problem while installing Snoopy which I couldn't resolve and couldn't find any answers to, so I spent over 8 hours figuring it out and I'm going to post it here so others don't need to struggle.
My problems were that the installation would fail when collecting PIL
The error was:
Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL
Another error I got was an issue with a python library:
Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-7DSxKG/pylibpcap/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-UmzXwX-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-7DSxKG/pylibpcap/
The last error I got was that the dpkt couldn't download because of a 404.
the error message I got was:
Collecting https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz
HTTP error 404 while getting https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz
Could not install requirement https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz because of error 404 Client Error: Not Found for url: https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz
Could not install requirement https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz because of HTTP error 404 Client Error: Not Found for url: https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz for URL https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz
After I fixed these errors snoopy installed perfectly, I'll post how I sloved all of these issues now.
I solved these issues by doing the following:
Execute the following commands in terminal.
apt-get update
apt-get upgrade
apt-get install python-libpcap
then either in terminal with nano or using your trusty text editor open the snoopy-ng install.sh:
In terminal cd to where install.sh is kept and type
nano install.sh
go to
echo "[+] Downloading dpkt..."
and by the link link which should be "https://dpkt.googlecode.com/files/dpkt-1.8.tar.gz"
change it to
http://pkgs.fedoraproject.org/repo/pkgs/python-dpkt/dpkt-1.8.tar.gz/0f8e5a4d4b2f5d5faaf7bbfbf3e1e8b7/dpkt-1.8.tar.gz
next save the install.sh, in nano do this by pressing ctrl + x this will exit the file and prompt you to save the file, press y to save changes next go to terminal and type
sudo sh install.sh
Voila! Snoopy should install without any issues.

Installing Bigquery command-line tool

I tried installing Bigquery command-line tool under Linux using "easy_install bigquery" as well as manually via "python setup.py install".
I got the message "Finished processing dependencies for Bigquery." without an error.
Still, when I type "bq", I get the message "command not found".
Is there anything else to do?
Can you try running the easy_install command with the --record=log.txt flag? It should then give you a list of the output files when it is completed in the log.txt file.
E.g.
$ sudo easy_install --record=log.txt --upgrade bigquery
....
Installing bq script to /usr/local/bin
....
$ cat log.txt
/usr/local/bin/bq
You might also try the --verbose option as well.
Had the same issue, you can try
pip install --upgrade google-cloud-bigquery