Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code formatting does not work in the latest version of libtinfo #3174

Closed
joeljosephreji opened this issue Feb 14, 2019 · 21 comments
Closed

Code formatting does not work in the latest version of libtinfo #3174

joeljosephreji opened this issue Feb 14, 2019 · 21 comments
Assignees
Labels
bug Feature: Code Formatting fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@joeljosephreji
Copy link

joeljosephreji commented Feb 14, 2019

Type: LanguageService

Describe the bug

  • OS and Version: Kubuntu 18.10
  • VS Code Version: 1.31.1
  • C/C++ Extension Version: 0.21.0
  • Other extensions you installed (and if the issue persists after disabling them): vscjava.vscode-java-debug, dbaeumer.vscode-eslint, redhat.java, james-yu.latex-workshop, felixfbecker.php-debug, felixfbecker.php-pack, felixfbecker.php-intellisense, ms-python.python, redhat.vscode-yaml
  • A clear and concise description of what the bug is.
    The code formatting does not work unless libtinfo5 package is installed. It shows a notification "Formatting failed" with the prompt to check the output window. The current package is libtinfo6 which comes installed in Kubuntu 18.10 as default and the package manager identifies libtinfo5 as the legacy version.

To Reproduce

  1. Install the Microsoft C/C++ extension in VS Code installed on a fresh Kubuntu 18.10 installation.
  2. Run the 'Format Document' command in the 'Command Palette' (or press Ctrl + Shift + I which is the default keybinding)
  3. Open the output window (Ctrl + J) and choose C/C++ in the drop down list.
  4. See error (error shown in the output window given below)

Expected behavior

The code will be formatted with proper indentation, spacing, etc.

Screenshots

Additional context

From the output window:
Formatting failed:
/home/user/.vscode/extensions/ms-vscode.cpptools-0.21.0/bin/../LLVM/bin/clang-format -style={ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, TabWidth: 2, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0 } -fallback-style=LLVM -sort-includes=0 -assume-filename=/home/user/program.c
  /home/user/.vscode/extensions/ms-vscode.cpptools-0.21.0/bin/../LLVM/bin/clang-format: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

-->I believe that giving the Microsoft C/C++ extension support for libtinfo6 will solve the problem.

@joeljosephreji joeljosephreji changed the title Code formatiing does not work in the latest version of libtinfo Code formatting does not work in the latest version of libtinfo Feb 14, 2019
@bobbrow
Copy link
Member

bobbrow commented Feb 14, 2019

We redistribute clang-format (we do not compile it). Are you able to run it directly in your terminal window? /home/user/.vscode/extensions/ms-vscode.cpptools-0.21.0/LLVM/bin/clang-format

@bobbrow
Copy link
Member

bobbrow commented Feb 14, 2019

Does LLVM distribute a version of clang-format that works for you without installing libtinfo5?

@sean-mcmanus
Copy link
Contributor

@joeljosephreji ...as in, do newer versions (or the Ubuntu 18 one) at http://releases.llvm.org/download.html that work for you? I believe we ship the Ubuntu 14 version (or maybe the 16 one?), so we might need to ship additional ones.

@penguingovernor
Copy link

I have the same issue running similar specs to OP except regular Ubuntu 18.10

Here is my output when I try to format the code using VSCode.

Formatting failed:
/home/jorge/.vscode/extensions/ms-vscode.cpptools-0.21.0/bin/../LLVM/bin/clang-format -style={BasedOnStyle: Google, ColumnLimit: 70} -fallback-style=LLVM -assume-filename=/home/jorge/Programming/testing/fishy/main.cpp
  /home/jorge/.vscode/extensions/ms-vscode.cpptools-0.21.0/bin/../LLVM/bin/clang-format: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

When running from the command line:

$ ./../../../.vscode/extensions/ms-vscode.cpptools-0.21.0/LLVM/bin/clang-format main.cpp 

./../../../.vscode/extensions/ms-vscode.cpptools-0.21.0/LLVM/bin/clang-format: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
zsh: exit 127   ./../../../.vscode/extensions/ms-vscode.cpptools-0.21.0/LLVM/bin/clang-format

As a work around I instsalled clang-format

sudo apt install clang-format

and then figured out where it lived in my system

which clang-format
# outputs: /usr/bin/clang-format

and used that output for the value in my settings.json

{
  "C_Cpp.clang_format_path": "/usr/bin/clang-format"
}

and everything seemed dandy!

@sean-mcmanus
Copy link
Contributor

That is strange because we have tested on Ubuntu 18 and formatting works for us. I ran ldd on the latest Ubuntu 18 clang 7 and it still has the libtinfo.so.5 dependency. Can you run "/usr/bin/clang-format --version" and "ldd /usr/bin/clang-format" to see what version it is and what libtinfo.so dependency it has?

@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state labels Feb 15, 2019
@penguingovernor
Copy link

@sean-mcmanus

$ /usr/bin/clang-format --version
clang-format version 7.0.0-3 (tags/RELEASE_700/final)

$ ldd /usr/bin/clang-format
	linux-vdso.so.1 (0x00007ffda8bf9000)
	libLLVM-7.so.1 => /usr/lib/x86_64-linux-gnu/libLLVM-7.so.1 (0x00007fc3d192a000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc3d17a0000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc3d15b6000)
	libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fc3d13ae000)
	libedit.so.2 => /usr/lib/x86_64-linux-gnu/libedit.so.2 (0x00007fc3d1176000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fc3d0f59000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fc3d0f4d000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc3d0f47000)
	libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fc3d0d1c000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc3d0cfb000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc3d0b6e000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc3d0b54000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fc3d59ad000)

@sean-mcmanus
Copy link
Contributor

@penguingovernor Okay -- we tested with Ubuntu 18.04 and not 18.10 -- the binary we ship appears to be incompatible with that OS, so the workaround you did is the recommended course until we can get an alternative binary.

@joeljosephreji
Copy link
Author

We redistribute clang-format (we do not compile it). Are you able to run it directly in your terminal window? /home/user/.vscode/extensions/ms-vscode.cpptools-0.21.0/LLVM/bin/clang-format

I haven't tried terminal editing and the formatting worked without the clang-format package installed

@joeljosephreji
Copy link
Author

Does LLVM distribute a version of clang-format that works for you without installing libtinfo5?

I don't have clang-format package installed

@joeljosephreji
Copy link
Author

@joeljosephreji ...as in, do newer versions (or the Ubuntu 18 one) at http://releases.llvm.org/download.html that work for you? I believe we ship the Ubuntu 14 version (or maybe the 16 one?), so we might need to ship additional ones.

I haven't tried out clang-format in my terminal at all. I have to check it out. When I did an apt search llvm and an apt search clang, the only package I found installed is libllvm7. I will test clang-format in my terminal and share the results here.

@joeljosephreji
Copy link
Author

@penguingovernor Okay -- we tested with Ubuntu 18.04 and not 18.10 -- the binary we ship appears to be incompatible with that OS, so the workaround you did is the recommended course until we can get an alternative binary.

Cool, so I guess from the looks of things clang-format6 (I got that by running ~/.vscode/extensions/ms-vscode.cpptools-0.21.0/bin/../LLVM/bin/clang-format --version) package is being shipped in the extensions which requires libtinfo5 package installed and the default clang-format for Ubuntu 18.10 is clang-format7 which requires libtinfo6 (which is installed by default). So, the solution would be to have the latest clang-format binaries isn't it?

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Feb 19, 2019

@joeljosephreji Yes, this is a breaking incompatibility change with Ubuntu 18.10 -- I don't know if that is "by design" or a bug with the OS. Ubuntu 18.10 itself distributes a specially compiled clang-format 7 with the libtinfo6 dependency, which is not available from the pre-built binaries on the LLVM download site. Ubuntu 18.04 doesn't have this issue. Until we can ship a special version for Ubuntu 18.10, users will have to manually install clang-format and set our C_Cpp.clang_format_path to reference that.

@joeljosephreji
Copy link
Author

@joeljosephreji Yes, this is a breaking incompatibility change with Ubuntu 18.10 -- I don't know if that is "by design" or a bug with the OS. Ubuntu 18.10 itself distributes a specially compiled clang-format 7 with the libtinfo6 dependency, which is not available from the pre-built binaries on the LLVM download site. Ubuntu 18.04 doesn't have this issue. Until we can ship a special version for Ubuntu 18.10, users will have to manually install clang-format and set our C_Cpp.clang_format_path to reference that.

Or the issue can be resolved by just installing libtinfo5 package in Ubuntu 18.10 and its variants.

@GiuseppeCesarano
Copy link

GiuseppeCesarano commented May 14, 2019

As i said in another similar issue, if you have libtinfo.so.6 you can create a simple system link instead of downloading new packages. Here's how!
Run: ls /lib/ | grep libtinfo
Then if you can see libtinfo.so.6
Run: sudo link /lib/libtinfo.so.6 /lib/libtinfo.so.5

@sean-mcmanus sean-mcmanus added bug Feature: Code Formatting and removed more info needed The issue report is not actionable in its current state labels May 29, 2019
@vindicatorr
Copy link

I see that folks are talking about clang/LLVM with regard to libtinfo, but out of curiosity I did a "pacman -Qo /usr/lib/libtinfo.so.6" (not .5 since it didn't exist) and I see it is owned by ncurses.
So... something is out of date?

I found it really odd that only now have I just encountered this issue.
In my other thread regarding /tmp/edg files, we've gone over the clang/gcc issue as well and I thought I had moved all over to gcc, but now this formatting thing also relates to clang for some reason.

Maybe I should just move over to clang and be done with gcc.

But yeah, after ln so.5 to so.6, formatting worked right away.

I see on my old OS partition, I already had that link and found the owner for that linkage is ncurses5-compat-libs which looks to only be available in the AUR.

@qt1
Copy link

qt1 commented Dec 17, 2019

Here is another workaround:

I have also tried 'sudo link /lib/libtinfo.so.6 /lib/libtinfo.so.5' (same as #GiuseppeCesarano suggested above).
It does work but it opens the door to dll hell, which can, someday, end in corrupted files.
Being a paranoid I took the longer way:

I have installed clang-format and friends, as described in the clang site

Then, following the path in the error report:

cd ~/.vscode/extensions/ms-vscode.cpptools-0.26.2/LLVM/bin
mv clang-format clang-format.bak
ln -s /usr/bin/clang-format clang-format

This works (Ubuntu 19.10). It calls the installed clang-format and relies on the integrity of its installation.

@Sam0523
Copy link

Sam0523 commented Dec 24, 2019

and used that output for the value in my settings.json

{
  "C_Cpp.clang_format_path": "/usr/bin/clang-format"
}

Could we make this default, and the shipped version as a fallback?

@sean-mcmanus
Copy link
Contributor

@Sam0523 We're tracking using the version on the path with #4618 .

@sean-mcmanus sean-mcmanus modified the milestones: 0.26.3, 1.0.0 Jan 22, 2020
@Colengms Colengms added the fixed Check the Milestone for the release in which the fix is or will be available. label Feb 4, 2020
@logoff
Copy link

logoff commented Feb 22, 2020

{
  "C_Cpp.clang_format_path": "/usr/bin/clang-format"
}

In Manjaro Linux the solution I found is similar. Installing clang-format:

pamac install clang-format-all-git

And then editing settings.json as @penguingovernor exposed in his comment.

@sean-mcmanus
Copy link
Contributor

Our Insiders release fixes the clang-format dependency problems: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders

@sean-mcmanus
Copy link
Contributor

0.27.0-insiders (accidentally) didn't have the new clang-format, but 0.27.0-insiders3 does.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Code Formatting fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

10 participants