![设置 Rails 时 bundle install 抛出语法错误](https://linux22.com/image/616258/%E8%AE%BE%E7%BD%AE%20Rails%20%E6%97%B6%20bundle%20install%20%E6%8A%9B%E5%87%BA%E8%AF%AD%E6%B3%95%E9%94%99%E8%AF%AF.png)
我正在尝试将 Rails 应用程序部署到 Passenger。
运行 bundle 时:
[ps93785]$ /usr/lib/ruby/gems/1.8/bin//bundle install
我明白了:
Gemfile syntax error:
/home/djwyatt/supplies.mighty-wash.com/public/Gemfile:33: syntax error,
unexpected ':', expecting kEND
gem 'sdoc', require: false
编辑1 如果 gem 文件为:,则为第 31-34 行:
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
这在我的本地环境中运行得很好,知道为什么它会给我的 VPS 带来问题吗?
编辑2 (我使用 Ruby 2.0 进行开发,我的 VPS 是 1.8)
以下是我在尝试升级时遇到的问题:
[ps93785]$ rvm upgrade 2.0
The source ruby was not a valid ruby string.
1.9.3 也不起作用
编辑3
(这有效)
rvm use 2.0
然后bundle install worked fantastic
。现在有一个新问题 - 转储如下:
[ps93785]$ rake about
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247/gems/uglifier-2.1.2/lib/uglifier.rb:3:in `require'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247/gems/uglifier-2.1.2/lib/uglifier.rb:3:in `<top (required)>'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
/home/djwyatt/supplies.mighty-wash.com/public/config/application.rb:7:in `<top (required)>'
/home/djwyatt/supplies.mighty-wash.com/public/Rakefile:4:in `require'
/home/djwyatt/supplies.mighty-wash.com/public/Rakefile:4:in `<top (required)>'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/home/djwyatt/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
答案1
首先,您需要在 Gemfile 中使用 ruby 1.8 语法:
group :doc do
gem 'sdoc', :require => false
end
其次,我不确定 Passenger 的最新版本是否支持 Ruby 1.8。即使支持,您也应该至少升级到 ruby-1.9.3。