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

Incorrect warning "no newline at end of file" #950

Closed
elmart opened this issue May 2, 2014 · 11 comments
Closed

Incorrect warning "no newline at end of file" #950

elmart opened this issue May 2, 2014 · 11 comments

Comments

@elmart
Copy link

elmart commented May 2, 2014

I'm receiving a "no newline at end of file" warning on a file that I positively know it has one (I can see it with xxd / hexdump). I would attach the file but I don't see how.

@vheon
Copy link
Contributor

vheon commented May 2, 2014

Does it happen only for that particular file or with every file? Could you specify some reproducible steps along with your settings as mentioned in CONTRIBUTING.md?

@elmart
Copy link
Author

elmart commented May 2, 2014

Hi, I know my issue report was very weak. I'm sorry for that.
I just became frustrated because of GitHub not allowing me attaching a file. Sorry again.

Here you have a link to a folder with some files belong to neovim's source code:
https://www.dropbox.com/sh/3tykgokhh5nn9g7/2JNCVESoLK

(Note: This problems happens with regular vim. I'm using vim to edit neovim's code).

From those files:

  • arabic.h
  • blowfish.h
  • crypt.h
  • cursor_shape.h

fail with the "no newline at end of file" warning.

The other ones don't.
All files are similar in the sense that they all end in single 0x0a.
I don't see a pattern for failure, but this happens for many more files.

Can you reproduce it?
I think you probably won't reproduce it unless you've got the whole project and semantic engine does the same compilation it's doing for me. I'm a contributor to neovim, so, if you are in the mood, I can guide you through downloading and building neovim for the first time.

Thanks.

@vheon
Copy link
Contributor

vheon commented May 2, 2014

I just downloaded arabic.h from your dropbox and I get the same warning. If I have some spare time I will look into this myself but I think @Valloric will be quicker than me finding the problem here...

@elmart
Copy link
Author

elmart commented May 2, 2014

Great that you could reproduce it. I honestly didn't think it was going to be so easily reproducible.
Ok. Waiting for news on this, then.

Thanks!

@Valloric
Copy link
Member

Valloric commented May 8, 2014

The error is coming from libclang, not YCM. I'm sure you could provide a compiler flag (in ycm_extra_conf.py) to turn off this warning.

@Valloric Valloric closed this as completed May 8, 2014
@elmart
Copy link
Author

elmart commented May 8, 2014

Well, of course I can disable the warning, but that's not a solution.
Also, this only happens for the compiling internally made by YCM. If I compile with the same warnings in the command line, both with clang and gcc, I don't get the warning.

@Valloric
Copy link
Member

Valloric commented May 8, 2014

Well, of course I can disable the warning, but that's not a solution.

It is as far as YCM is concerned since if there's a bug here, it's in clang, not YCM. Nothing in YCM produced that error message.

Also, this only happens for the compiling internally made by YCM. If I compile with the same warnings in the command line, both with clang and gcc, I don't get the warning.

When you call clang-the-binary, it uses some default compilation flags that you probably aren't setting in your extra conf file. We can't set them for you because they differ based on OS, configuration etc. See #303 for that.

@elmart
Copy link
Author

elmart commented May 8, 2014

I understand what you say. But I still think there's something weird somewhere. Let me explain.
Neovim uses CMake to build.
We compile at the command line with well-defined flags (you can see them at https://github.com/neovim/neovim/blob/master/CMakeLists.txt#L26).
We then use a .ycm_extra_conf.py that automatically extracts whatever flags you have used to compile in the command line. You can see this .ycm_extra_conf.py at https://github.com/neovim/neovim/blob/master/contrib/YouCompleteMe/ycm_extra_conf.py
I think there must be something wrong in our cmake chain or we have misunderstood something in the way we can instruct YCM to use the same flags cmake uses.
So, I will give a careful look to our cmake chain, to see if something has gone out of sync somewhere.
It would be great if you could give a quick glimpse (it's a very short file) to https://github.com/neovim/neovim/blob/master/contrib/YouCompleteMe/ycm_extra_conf.py and tell us if you see something wrong there.
Thanks.

@Valloric
Copy link
Member

Valloric commented May 8, 2014

At a quick glance, I see nothing obviously wrong in the extra conf file you linked.

After you get the compile commands from the json file, you may need to add some more flags to them before returning them to YCM. You are assuming that whatever flags you use with clang-the-binary to compile successfully should automatically work without changes when given to libclang-the-library through YCM. I'd love it if that were the case, but it often isn't (again, see #303 for examples and background detail).

Get the flags from the cmake-provided json file and then modify them as needed to compile without errors through libclang. Then pass the flags to YCM.

@elmart
Copy link
Author

elmart commented May 8, 2014

Now I get you. I'll give that a try. Thanks!.

elmart added a commit to elmart/neovim that referenced this issue Oct 20, 2014
Problem:  YCM was reporting a much disturbing warning about a missing
          newline at the end of some files. This was odd, as the
          newlines were there and the warning only was shown for some
          files, not for all of them.
Cause:    After discussing this issue with @Valloric (see
          ycm-core/YouCompleteMe#950), it
          turned out that not YCM, but libclang is responsible for it.
          This is, same compilation flags that produce no warnings with
          clang-the-binary on the command line, do produce them with
          libclang-the-library when used by YCM.
Solution: Add an extra flag (-Wno_newline_eof) to those extracted from
          configuration database before passing them to YCM.
tarruda pushed a commit to neovim/neovim that referenced this issue Oct 20, 2014
Problem:  YCM was reporting a much disturbing warning about a missing
          newline at the end of some files. This was odd, as the
          newlines were there and the warning only was shown for some
          files, not for all of them.
Cause:    After discussing this issue with @Valloric (see
          ycm-core/YouCompleteMe#950), it
          turned out that not YCM, but libclang is responsible for it.
          This is, same compilation flags that produce no warnings with
          clang-the-binary on the command line, do produce them with
          libclang-the-library when used by YCM.
Solution: Add an extra flag (-Wno_newline_eof) to those extracted from
          configuration database before passing them to YCM.
victorfonsec4 pushed a commit to victorfonsec4/neovim that referenced this issue Oct 20, 2014
Problem:  YCM was reporting a much disturbing warning about a missing
          newline at the end of some files. This was odd, as the
          newlines were there and the warning only was shown for some
          files, not for all of them.
Cause:    After discussing this issue with @Valloric (see
          ycm-core/YouCompleteMe#950), it
          turned out that not YCM, but libclang is responsible for it.
          This is, same compilation flags that produce no warnings with
          clang-the-binary on the command line, do produce them with
          libclang-the-library when used by YCM.
Solution: Add an extra flag (-Wno_newline_eof) to those extracted from
          configuration database before passing them to YCM.
@azjps
Copy link

azjps commented Nov 13, 2014

How do I try compiling with "libclang-the-library through YCM"? YCM is displaying some errors that I don't see when passing the same compilation flags to clang(-the-binary). (Sorry if its a silly question, but I didn't see how to do this on a glance through the docs.)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants