Can't get Rubymine to recognize .rb file as Ruby

已完成

I created a controller file by hand in Rubymine named businesses_controller.rb. While creating the file, I created it as a text file, and not a Ruby file. I also did not use any of the generators to create this controller.

Syntax highlighting did not work, so I deleted that file and recreated it using the controller generator. Unfortunately, the file still shows up as a text file, and since Rubymine does not recognize it as a Ruby file, autocompletion does not work for this controller either.

I tried Invalidating Caches, and Reloading from Disk but unfortunately that didn't work. I also removed the entire directory, and downloaded a fresh copy from our subversion project, and tried creating the controller again in a completely separate directory. But Rubymine still did not recognize it as a Ruby file.

Also tried creating a completely new project from scratch with a controller named businesses_controller.rb and it still showed up as a text file. I think this particular filename has been permanently cached somewhere as a non-Ruby file. Is there some other configuration that we are supposed to clear besides invalidating caches, or reloading from disk? Could this be a bug? My version of Rubymine is 3.1.1, Build RM# 103.260 running on OSX (Snow Leopard).

2

Please ignore this post. It was a user error. Somehow the pattern businesses_controller.rb explicitly got registered as a text file. Removed that and it works great. Thanks!

1

Thanks for updating the post, develop with pleasure!

Regards,
Oleg

0
I realise this is an old thread, however 2 years on I also have exactly this problem, where I have created a file as a text file by accident.  I then proceeded to delete this file, and create a new file as a Ruby class, however now Rubymine is only registering this file as a text file.  If I rename the file to any other name it will register correctly as a Ruby file, however it seems this file name is permanently stuck as a text file.

I see your fix "Somehow the pattern businesses_controller.rb explicitly got registered as a text file. Removed that and it works great."... can you please outline how to do this?  Thanks!
1

Hi,

try File|Settings|File Types.

Regards, Oleg.

4

Thank you Oleg, you were correct - my file name was under the registered patterns as a text file.

Just a note, I think this is strange Rubymine behaviour; in my opinion it is an unexpected side effect that when creating a new file text file, that the name of that file is registered as a pattern under that file type (in this case, text).  Especially in Ruby where many things are down to convention, most users would have text files as .txt, and ruby files as .rb.  If users want to register more patterns or file names to enforce certain files to be opened as a certain type, I think this should be an explicit action on the users part rather than something happening behind the scenes like this.

0

Hi,

as far as I remember when you create a new file and RM is unable to decide what type the file should have it asks you to select type.
After that it remember your choice by modifying file types' settings.  So, this is an explicit action.
If you have different experience please describe the scenario in which RM does this implicitly.

Regards, Oleg.

0

Hi,

I'm experiencing the same problem, but not finding this path: File|Settings|File Types.

Regards,

 

Devan

1

Found the solution. 

Path for Mac > RubyMine | Preferences | Editor | File Types for macOS 

2

There must be some sort of keyboard/context menu shortcut to do this, because I just experienced it with a file that has existed for years!

And thanks for the help finding that path in macOS settings @Dmmoylan. I was struggling to find it as well.

0

Just had the same problem, RubyMine told me to download IntelliJ Ultimate in order to recognize ruby files for the one file lol. 

0

While working, I received a message to use intellij to recognize my files.  I hit ignore and now my file is lacking syntax highlighting.  If I change the name, the file will regain its type, but if I use the same file name it goes back to being a plain text file.  I've messed around in the file types menu in preferences, but it has no effect.  I've tried all the options when the IntelliJ suggestion comes up and none of them do anything other than bring up the file types menu.   This has been an issue for almost 10 years, how about a fix?

0

@J Marcus1943, could you please check that this file name pattern isn't registered in Preferences | File Types | Text?

0

That's exactly what I was looking for in this menu.  Everything appears normal but once the suggestion to use IntelliJ ultimate pops up, the file loses its identity.  Newly created files will work fine, but the file that was open during this popup message becomes useless.  I have created multiple projects and they all have had this happen at some point.

0

I'm experiencing this same issue. I have performed all of the steps mentioned here. Invalidate Cache/restart, Ensure that *.rb is not in the registered pattern for txt, even deleting the file/project and re creating/cloning. The file icon shows a ruby file, yet there is no syntax highlighting and I can not click to go to definition of method. It doesn't recognize spacing/formatting that is defined for other ruby file either.

0

Hello Michael,

does it happen in 2019.2? Is it for all Ruby files or only a certain one? Do you have any 3rd party plugins installed? (if so then please try disabling them)

1

Nope, I was not aware of the 2019.2 update. Just updated and all is well now. Thank you so much :D

0

Having this problem in 2020. File/Settings/File Types didn't seem to have any relevant information. 

Description of problem: Created a new file without extension, defaulted to text type. Refactor/Renamed to add .rb extension, RubyMine still did not recognize as Ruby file. Deleted file and created new module with same name, that file also was not recognized as a Ruby file, but as text. 

0

Hello Matt, 

could you please attach a screenshot showing the problem. Does it happen with all the new modules you create?

0

This just happened to me too.

Run through the following steps to reproduce the issue and solution:

1. Create a new file with no extension.
2. Click Ok because you're not paying attention.

3. Change the File pattern text field to `test_auto_register.rb` because you're still not paying attention.
4. Add some text to the file and notice that syntax highlighting is missing.
5. Right-click the file and Refactor -> Rename the file to an `*.rb` extension.
6. Go back to the file and notice that syntax highlighting is still missing.
7. Delete the file and recreate it directly as `test_auto_register.rb`, it's not going to help.
8. Go to RubyMine -> Preferences -> Editor -> File Types and select Auto-detect file type by content.
9. Click the file name and click the `-` sign to remove the association.
10. Syntax highlighting will now (hopefully) be back for your file.

0

Thanks for the help, all. I will try these steps next time this occurs. This time around I ended up choosing a different filename, which also worked.

0

RubyMine 2021.2 (Windows 10)

Was able to find and remove my custom file name pattern in,
File -> Settings -> Editor -> File Types -> File type auto-detected by file content

0

For some reason, the message persists and won't go away or let me hit "dismiss"

Also, adding *.rb to recognized file types doesn't seem to do anything

 

0

Micah Rothenbuhler, .rb files should not be added to Text file type unless you want them to be recognized as text and not Ruby. Instead please check that you have Ruby plugin installed and enabled, in this case there will be Ruby file type. In addition, according to your screenshot you have a Java module configured so could you please re-import it as a Ruby one (via File - Project Structure - Modules)

0

请先登录再写评论。