Home>

I'm having trouble getting an error when doing rails new.

Error message
bundler: failed to load command: rails (/Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/bin/rails)
SyntaxError: /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt : 10: syntax error, unexpected ')', expecting end-of-input
);if spring_install?
^
  /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/erb.rb:885:in `eval '
  /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/erb.rb:885:in `result '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/file_manipulation.rb:131:in `block in template '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/create_file.rb:53:in `render '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke! '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `open '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/create_file.rb:63:in `block in invoke! '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/empty_directory.rb:117:in `invoke_with_conflict_check '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/create_file.rb:60:in `invoke! '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions.rb:94:in `action '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/create_file.rb:25:in `create_file '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/file_manipulation.rb:122:in `template '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/directory.rb:92:in `block in execute! '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/directory.rb:80:in `each '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/directory.rb:80:in `execute! '/Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/directory.rb:66:in `invoke! '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions.rb:94:in `action '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions/directory.rb:52:in `directory '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/generators/rails/app/app_generator.rb:19:in `directory '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/generators/rails/app/app_generator.rb:115:in `block in config '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions.rb:188:in `block in inside '
  /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/fileutils.rb:122:in `chdir '
  /Users/username/.rbenv/versions/2.5.0/lib/ruby/2.5.0/fileutils.rb:122:in `cd '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/actions.rb:188:in `inside '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/generators/rails/app/app_generator.rb:19:in `inside '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/generators/rails/app/app_generator.rb:106:in `config '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/generators/app_base.rb:156:in `build '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/generators/rails/app/app_generator.rb:319:in `create_config_files'
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/commands/application/application_command.rb:26:in `perform '/Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/command/base.rb:65:in `perform '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/command.rb:46:in `invoke '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/lib/rails/cli.rb:18:in `<top (required)>'
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/exe/rails:10:in `require '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/gems/railties-6.0.1/exe/rails:10:in `<top (required)>'
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/bin/rails:23:in `load '
  /Users/username/Desktop/vue_rails/vendor/bundle/ruby/2.5.0/bin/rails:23:in `<top (required)>'
Applicable source code
bundle exec rails new task

I found a person with a similar error, so I tried the solution he had done, but it was no good.
https://www.tutorialfor.com/go.php?id=184585

Supplemental information (FW/tool version etc.)

ruby ​​-v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin18]

bundle -v
Bundler version 2.0.2

bundle exec rails -v
Rails 6.0.1

  • Answer # 1

    I was drafted here,
    This seems to be a bug caused by ruby ​​2.5.0 ERB compatibility.

    There are two ways to solve this.

    Increase ruby ​​version

    Fix the location where syntax error occurs.

    For

    1, I think that you can upgrade ruby ​​to your environment.

    Please try to modify

    2 as follows.

    File to be modified
    Project directory name/vendor/bundle/ruby ​​/ 2.5.0/gems/railties-6.0.1/lib/rails/generators/rails/app/templates/config/environments/test.rb

    # test.rb line 10
    <%-# Spring performs the reloaders when files change.%>
    # ↓ Changed to the following description
    <%-# Spring performs the reloaders when files change .-%>