Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bundle install error, unexpected ':'

I know there are bunch of question or similar on the web, but it doesn't fit my case. I'm installing redmine, and when I call bundle install, I get this error :

[!] 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.

The error is on this line (the one prefixed by ->):

   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

like it's said in so many other threads, a cause could be that this code use the "new" ruby 1.9 hash syntax. However, looking at the versions:

$ 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

EDIT: as suggested by Arsen, this command shows where is the problem, I'll read some documentations about ruby and virtual environments to get it work the right way :

$ 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

Then, I think gem is using ruby 2.2 (but I'm not sure) so I think there shouldn't be any problem, but since I don't really know the ruby universe and there is actually an error, I'm certainly wrong. That's why I request the help of the community...

So any ideas of what is going on ?

(I could correct the file using the old hash syntax, but since I would like to use the latest versions, I think that would only move the problem)

like image 497
hl037_ Avatar asked Sep 13 '15 12:09

hl037_


1 Answers

This is a old question but since it is unsolved and I ran into the same problem I'll share my solution.

I installed ruby via apt-get on my debian 7 server. When trying to run bundle install I got the same error message as above:

[!] There was an error parsing Gemfile: compile error - syntax error, unexpected ':', expecting $end

My soultion was to install ruby via ruby version manager.

  1. Remove ruby sudo apt-get remove ruby && sudo apt-get autoremove
  2. Install ruby via ruby version manager (rvm) \curl -sSL https://get.rvm.io | sudo bash -s stable --rails
  3. If 2. fails, add signature (as prompted) \curl -sSL https://get.rvm.io | sudo bash -s stable --rails
  4. Add user to group sudo usermod -aG rvm USERNAME && sudo usermod -aG rvm www-data
  5. Logout & login
  6. Re-run your bundle install command
  7. If you still have problems they should be application relevant. For me I additionally had to install sudo apt-get install libmysqlclient-dev.

I've seen this solution while following a tutorial on this blog

like image 92
clinical Avatar answered Oct 04 '22 09:10

clinical