简体   繁体   English

使用 ruby 1.9.3 运行“rake db:setup”时出现语法错误

[英]Syntax error when i run 'rake db:setup' while using ruby 1.9.3

I get a syntax error when i try to run 'rake db:setup'.当我尝试运行“rake db:setup”时出现语法错误。 I didn't face any problems when i ran 'bundle install' I'm trying to get the Typo app (from the saasbook) running.当我运行“捆绑安装”时,我没有遇到任何问题,我试图让 Typo 应用程序(来自 saasbook)运行。 I'm using Ruby 1.9.3 and rails '3.0.10'我正在使用 Ruby 1.9.3 和 rails '3.0.10'

ubuntu:~/environment/typo (master) $  rake db:setup
/home/ubuntu/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:24:in `eval': /home/ubuntu/.rvm/rubies/ruby-1.9.3-p551/bin/rake:4: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
exec "$bindir/ruby" -x "$0" "$@"
                        ^
        from /home/ubuntu/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:24:in `<main>'

This is my Gemfile这是我的宝石文件

env = ENV["RAILS_ENV"] || 'development'
dbfile = File.expand_path("../config/database.yml", __FILE__)



source 'https://rubygems.org'
ruby "1.9.3"

gem 'thin'
gem 'rails', '~> 3.0.10'
gem 'require_relative'
gem 'htmlentities'
gem 'json'
gem 'bluecloth', '~> 2.1'
gem 'coderay', '~> 0.9'
gem 'kaminari'
gem 'RedCloth', '~> 4.2.8'
gem 'addressable', '~> 2.1', :require => 'addressable/uri'
gem 'mini_magick', '~> 1.3.3', :require => 'mini_magick'
gem 'uuidtools', '~> 2.1.1'
gem 'flickraw-cached'
gem 'rubypants', '~> 0.2.0'
gem 'rake', '~> 0.9.2'
gem 'acts_as_list'
gem 'acts_as_tree_rails3'
gem 'recaptcha'
gem 'pg'

group :development, :test do
  gem 'ruby-debug19'
  gem 'factory_girl', '~> 2.2'
  gem 'webrat'
  gem 'rspec-rails', '~> 2.0'
  gem 'simplecov', :require => false
  # gem 'sqlite3'
  gem 'cucumber'
  gem 'cucumber-rails', :require => false
  gem 'cucumber-rails-training-wheels'
  gem 'database_cleaner'
  gem 'capybara'
end

How do i resolve this?我该如何解决这个问题?

There is a problem with rake.耙子有问题。 Reinstall rake using the same version specified in the Gemfile can solve the problem.使用 Gemfile 中指定的相同版本重新安装 rake 可以解决问题。 gem install rake -v 0.9.2

Ruby(1.9.3) on Rails(3.0.10) is not compatible with Postgresql 10. You have to use Postgresql 9 or a lower version with Rails 3. I was running the app on AWS Cloud9 - Ubuntu 18. By default sudo apt-get install postgresql will install postgresql 10. So using an older version might work. Ruby(1.9.3) on Rails(3.0.10) is not compatible with Postgresql 10. You have to use Postgresql 9 or a lower version with Rails 3. I was running the app on AWS Cloud9 - Ubuntu 18. By default sudo apt-get install postgresql将安装 postgresql 10。因此使用旧版本可能会起作用。

PS - Switching to AWS Linux from Ubuntu and running the app worked. PS - 从 Ubuntu 切换到 AWS Linux 并运行该应用程序有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM