我知道网上有很多问题或类似问题,但它不适合我的情况。
我正在安装 redmine,当我调用 bundle install
时,出现此错误:
[!] There was an error parsing `Gemfile`: compile error - syntax error, unexpected ':', expecting $end
gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin, :jruby]
^. Bundler cannot continue.
错误在这一行(以->
为前缀的那一行):
source 'https://rubygems.org'
if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.5.0')
abort "Redmine requires Bundler 1.5.0 or higher (you're using #{Bundler::VERSION}).\nPlease update with 'gem update bundler'."
end
gem "rails", "4.2.3"
gem "jquery-rails", "~> 3.1.3"
gem "coderay", "~> 1.1.0"
gem "builder", ">= 3.0.4"
gem "request_store", "1.0.5"
gem "mime-types"
gem "protected_attributes"
gem "actionpack-action_caching"
gem "actionpack-xml_parser"
gem "loofah", "~> 2.0"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
-> gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin, :jruby]
gem "rbpdf", "~> 1.18.6"
# Optional gem for LDAP authentication
group :ldap do
gem "net-ldap", "~> 0.3.1"
end
就像在许多其他线程中所说的那样,原因可能是这段代码使用了“新的”ruby 1.9 哈希语法。但是,查看版本:
$ ruby -v
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
$ gem -v
2.2.2
$ bundle -v
Bundler version 1.10.6
$ bundle exec ruby -v
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
$ which bundler
/usr/local/bin/bundler
编辑:按照 Arsen 的建议,此命令显示问题出在哪里,我将阅读一些有关 ruby 和虚拟环境的文档以使其以正确的方式工作:
$ bundle env
Environment
Bundler 1.10.6
Rubygems 1.8.24
Ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
Git 2.5.1
Bundler settings
without
Set for your local app (/home/leo/http/redmine.leo-flaventin.com/redmine/.bundle/config): "development:test"
Gemfile
[...] #The redmine Gemfile
然后,我认为gem正在使用ruby 2.2(但我不确定)所以我认为应该没有任何问题,但由于我并不真正了解ruby universe并且实际上存在错误,我肯定错了。这就是为什么我请求社区的帮助......
那么对正在发生的事情有什么想法吗?
(我可以使用旧的哈希语法更正文件,但由于我想使用最新版本,我认为这只会解决问题)
最佳答案
这是一个老问题,但由于它尚未解决并且我遇到了同样的问题,所以我将分享我的解决方案。
我通过 apt-get 在我的 debian 7 服务器上安装了 ruby。尝试运行 bundle install 时,我收到与上述相同的错误消息:
[!] 解析 Gemfile
时出错:编译错误 - 语法
错误,意外的 ':',期待 $end
我的想法是通过 ruby 版本管理器安装 ruby。
- 删除 ruby
sudo apt-get remove ruby && sudo apt-get autoremove
- 通过 ruby 版本管理器 (rvm) 安装 ruby
\curl -sSL https://get.rvm.io | sudo bash -s stable --rails
- 如果 2. 失败,添加签名(根据提示)
\curl -sSL https://get.rvm.io | sudo bash -s stable --rails
- 将用户添加到组
sudo usermod -aG rvm USERNAME && sudo usermod -aG rvm www-data
- 注销和登录
- 重新运行您的
bundle install
命令 - 如果您仍然有问题,它们应该与应用程序相关。对我来说,我还必须安装
sudo apt-get install libmysqlclient-dev
。
我在学习有关此 blog 的教程时看到了此解决方案
关于ruby-on-rails - bundle 安装错误,意外 ':',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32549499/