1

rails -v

Activating the command above results in:

bin/rails: 7: bin/rails: Syntax error: "(" unexpected

My rails in engine seems to not be running correctly, and is not responding.

It tells about syntax error when I try to call rails -v, or rails db:create or something like that.

rails s returns the same error

Here is the rest of the .gemspec file I used:

# frozen_string_literal: true

$:.push File.expand_path('lib', __dir__)

# Maintain your gem's version:
require 'vulnerabilities/version'

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
  s.name        = 'vulnerabilities'
  s.version     = Vulnerabilities::VERSION
  s.authors     = ['Evgeny Karpenko']
  s.email       = ['[email protected]']
  s.homepage    = 'https://new.docshell.ru'
  s.summary     = 'Vulnerabilities Plugin for Docshell4'
  s.description = 'VulnerabilitiesPlugin for Docshell4'
  s.license     = 'proprietary'

  s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']

  s.add_dependency 'rails', '~> 5.1.6', '>= 5.1.6.1'

  s.add_dependency 'active_model_serializers', '~> 0.10.7'
  s.add_dependency 'kaminari', '~> 1.1', '>= 1.1.1'
  s.add_dependency 'pg', '~> 1.1', '>= 1.1.2'
  s.add_dependency 'swagger-blocks', '~> 2.0.2'
  s.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'

  s.add_development_dependency 'annotate'
  s.add_development_dependency 'database_cleaner'
  s.add_development_dependency 'factory_bot_rails'
  s.add_development_dependency 'faker'
  s.add_development_dependency 'rspec'
  s.add_development_dependency 'rspec-instrumentation-matcher'
  s.add_development_dependency 'rspec-rails'
  s.add_development_dependency 'shoulda-matchers'
end

here is the bin/rails file, which can not run File.expand_path

# frozen_string_literal: true

#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/vulnerabilities/engine', __dir__)
APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

require 'rails/all'
require 'rails/engine/commands'
4
  • Run rails server to see the full stack trace and you might be able to find the syntax error Commented Jun 5, 2019 at 12:27
  • 2
    Is that the full error? Just one line? Nothing more in the backtrace? Commented Jun 5, 2019 at 12:30
  • And to be clear, is it complaining about line 7: ENGINE_ROOT = File.expand_path('..', __dir__) ? I don't see anything wrong with that line, but what happens if you comment it out? Commented Jun 5, 2019 at 12:31
  • Tom Lord, it's the only error, one string. If I comment it - the error appears on next line. The reason is my rails broken there. Commented Jun 5, 2019 at 12:38

1 Answer 1

3

The reason was in this line:

# frozen_string_literal: true

after removing it - rails starts to work properly

this line appeared due to RuboCop intervention

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.