Search code examples
ruby-on-railsdartrubymine

Dart Analyzer in a Rail Project is Giving an Error on a Template File


I'm trying to set up the dart-rails gem. When I created my first dart code file, I got this error:

ERROR: Target of URI does not exist: 'package:rails_ujs/rails_ujs.dart' ([dart_app] dart_app.dart:1)

When I double click on the error, it brings up the following file.

app/vendor/bundle/gems/dart-rails-0.4.3/lib/dart/rails/generators/templates/dart/dart_app.dart

This is the contents of the file:

import 'package:rails_ujs/rails_ujs.dart';

RailsUjs ujsHelper;

void main() {
  ujsHelper = new RailsUjs();
}

I have this same file in my app/assets/dart directory as well as the package itself. That file is not showing an error. If I change the code to something invalid, an error pops up. This proves the analyzer is looking at it as well.

The error pops up when I run Reanalyze all Dart source files (without restarting Dart Analysis Service). This is a button in the RubyMine IDE. I tried restarting the service and reanalyzing. I get the same error. This issue seems to be that the analyzer is scanning the entire project for dart files. Is it possible to control where the analyzer looks? It's RubyMine that is running the analyzer, not me at a terminal prompt.


Solution

  • This turned out to be a RubyMine issue. I fixed it by placing a file called .analysis_options in the root of the project with the following contents:

    analyzer:
      exclude:
        - 'vendor/**'
    

    I just excluded everything in the vendor directory. Even when I was getting the error, the analyzer continued to process all the valid code files.