Gemfile when developing between two platforms - ruby

I am carrying out some development of a Ruby on Rails app between a Windows machine and linux machine. Not ideal but Ruby on Windows has improved a lot. Anyway i read that you can implement an IF statement so for example I have implemented this
source 'https://rubygems.org'
if RUBY_PLATFORM =~ /win32/
gem 'rails', '3.2.3'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'nokogiri'
gem 'httparty'
gem 'devise'
else
gem 'rails', '3.2.3'
gem 'sqlite3', '1.3.6'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'less-rails'
gem 'uglifier', '>= 1.0.3'
gem 'execjs'
gem 'therubyracer', '0.10.2'
end
gem 'jquery-rails'
gem 'nokogiri'
gem 'httparty'
gem 'devise'
end
So this morning I merged my linux branch into the master branch (windows) and now i get the message
Could not find the less-rails in any of the sources
So it seems as if the IF statement has not worked or there is an issue with my bootstrap.css.less file in assets as I use this in my linux branch
How can i get this to work, so either have less working on both platforms or get windows to ignore the less gem
has anyone got around this before
UPDATE
Ok so i have found that if I specify
:platform => :ruby
after the less-rails gem it ignores it (though I had to add to execjs and rubyracer aswell) due to js runtime conflicts.. So question still remains as to what is wrong with my IF/ELSE statement
Thanks

Have you rebuilt the bundle lock file?
Try this on your Windows machine:
bundle install
bundle update
To learn about bundle, Gemfile, Gemfile.lock, and why you need to rebuild the lock when you switch platforms: http://gembundler.com/rationale.html

Related

bundle install error - Your bundle only supports platforms [] but your local platforms are ["ruby", "x86_64-linux"]

Getting this error doing a bundle install; google around seems like a common issue but I can't seem to find the fix (seem suggestion on Gemfile.lock but I moved that file to another directory)
# bundle install
Your bundle only supports platforms [] but your local platforms are ["ruby", "x86_64-linux"], and there's no compatible match between those two lists.
Here's my Gemfile and there is no Gemfile.lock in the directory.
[root#ip-172-30-4-16 rails]# gem -v
2.6.11
[root#ip-172-30-4-16 rails]# ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
[root#ip-172-30-4-16 rails]# bundle -v
Bundler version 1.14.6
[root#ip-172-30-4-16 rails]# cat Gemfile
source 'http://rubygems.org'
gem 'echoe'
gem 'rails', '~> 3.2.11'
gem 'mysql2'
gem 'prawn', '~> 0.5.0.1'
gem 'prawn-core', '~> 0.5.0.1', :require => 'prawn/core'
gem 'prawn-layout', '~> 0.2.0.1', :require => 'prawn/layout'
gem 'prawn-format', '~> 0.2.0.1', :require => 'prawn/format'
gem 'spreadsheet', '~> 0.6.5'
gem 'libxml-ruby', :require => 'libxml_ruby'
gem 'faker'
gem 'json'
gem 'rake'
gem 'jquery-rails'
gem 'therubyracer'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'memcache-client'
gem 'rb-readline'
gem 'rubyzip', '~> 1.0.0'
gem 'zip-zip' # Rubyzip old API compatibility addon
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
#group :development do
# gem 'ruby-debug19'
#end
group :test do
gem 'flexmock', '= 0.9.0'
gem 'machinist', '= 2.0'
gem 'test-unit', '~> 1.2.3'
# Use SimpleCov and Coveralls for test coverage reports
gem 'simplecov'
gem 'coveralls'
end
group :production do
gem 'passenger'
end
group :test, :development do
gem 'rspec-rails', '~> 2.0'
end
I had the same issue, I had to remove the .bundle directory and then bundle install worked.
I was able to work around issue /w bundle install --no-deployment option
If you get this error when using GitHub Actions, you can fix it by adding the Ruby platform to your Gemfile.lock:
$ bundle lock --add-platform ruby
Then commit, and push your change.

Install gem from github using Rail 3

I need to install wicked_pdf gem from github. I also updated Gemfile but when I run bundle install it gave me the following message.
You need to install git to be able to use gems from git repositories. For help
installing git, please refer to GitHub's tutorial at
https://help.github.com/articles/set-up-git
I have the Gemfile which is given below.
Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.19'
gem 'mysql'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem "bcrypt-ruby", :require => "bcrypt"
gem 'momentjs-rails', '>= 2.8.1'
gem 'bootstrap3-datetimepicker-rails', '~> 4.0.0'
gem 'bootstrap-datepicker-rails', '>= 0.6.21'
gem 'will_paginate', '~> 3.0'
gem 'wicked_pdf', :github => 'mileszs/wicked_pdf', :branch => 'master'
I have already installed git-cell on my system and i am using win-7 64 bit. Please help me to resolve this issue.

Gem syntax error questions

I can't figure out what's wrong with my syntax in my Gemfile. Any time I try to run $ bundle install I get this error message:
Gemfile syntax error:
ruby ‘2.1.1’
^
/Users/[User]/Work/application/Gemfile:2: syntax error, unexpected tFLOAT, expecting '('
ruby ‘2.1.1’
I have tried adjusting the gemfile to different versions of ruby that I have running on my system, but it gives me the same error message. The carrot underneath the version number is also always in the same place. This is my Gemfile:
source 'https://rubygems.org'
ruby ‘2.1.1’
gem 'coffee-rails', '~> 4.0.0'
gem 'jbuilder', '~> 1.2'
gem 'jquery-rails'
gem 'rails', '4.0.2'
gem 'rails_12factor'
gem 'sass-rails', '~> 4.0.0'
gem 'turbolinks'
gem 'uglifier', '>= 1.3.0'
gem 'authlogic'
gem 'aws-s3'
gem 'google-api-client', :require => 'google/api_client'
gem 'google_visualr', '>= 2.1'
gem 'haml-rails'
gem 'httparty'
gem 'mysql2'#, '0.3.12b4'
gem 'nokogiri'
gem 'oauth2'
# gem 'pg'
gem 'redis'
gem 'resque'#, '~> 1.22.0'
gem 'rmagick', require: 'RMagick'#, '2.12.0'
gem 's3_direct_upload'
gem 'sendgrid'
gem 'scout'
gem 'thinking-sphinx'#, '3.0.3'
gem 'unicorn'
group :development do
gem 'dotenv-rails' # for dan 'cause he uses pow
gem 'foreman' # for dan 'cause he uses pow
gem 'mailcatcher'
gem 'annotate'
end
group :doc do
gem 'sdoc', require: false
end
What am I missing?
I had opened the gemfile in Text Edit and it replaced the single quotes with different ASCII encoded quotes. Opened it in Sublime 2 and replaced the single quotes and that fixed it.

Bundle without -j4 on Heroku

Heroku seems to now default to parallel bundling with -j4 because I see in the push log:
Running: bundle install --without development:test:staging --path
vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
This throws an error which I can replicate locally with
bundle install -j4
The error locally is:
/Users/Emma/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/thread.rb:72:in `sleep': No live threads left. Deadlock? from /Users/Emma/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/thread.rb:72:in `block (2 levels) in wait'
The error when I attempt deployment is:
/tmp/build_a49f4fc2-73b3-4101-9b67-f795fa643429/vendor/ruby-2.0.0/lib/ruby/2.0.0/thread.rb:72:in `sleep': No live threads left. Deadlock? (fatal)
How can I force Heroku to stop attempting to bundle gems in parallel?
edit: gemfile
ruby '2.0.0'
source 'http://rubygems.org'
# Rails
gem "rails", "~> 3.2.13"
gem 'rake', '10.1.0'
gem 'rails_12factor', group: :production
# Basic libraries
gem "unicorn", "4.6.2"
gem 'jquery-rails', '2.1.4'
gem 'nokogiri'
gem 'bundler'
gem "activesupport"
gem 'aws-s3'
gem 'aws-sdk' #required in 3.1.3 to get rake to work -- taken out may 13 as conflicts with s3
gem 'hirefireapp'
gem "hirefire-resource"
gem 'newrelic_rpm', "~> 3.6.5.130"
gem 'modernizr-rails'
gem 'gocardless'
# Background processing
gem 'delayed_job_active_record' #required in 3.1.3 to get DJ to work
gem "SystemTimer", :require => "system_timer", :platforms => :ruby_18
gem "rack-timeout"
gem 'delayed_paperclip' , '2.4.5.2' # , :git => 'git://github.com/tommeier/delayed_paperclip', :branch => 'fix_312'
# Views
gem 'haml'
gem 'rdiscount', "~> 1.6.8" #manually included -- it's a dependency of simple tooltip
gem 'simple-tooltip', "~> 0.0.2"
gem 'will_paginate', '~>3.0'
gem 'will_paginate-bootstrap', '0.2.1'
gem 'gritter_notices', '~>0.3.4' #, :git => 'git#github.com:ck3g/gritter_notices.git'
gem "ariane"
gem 'bootstrap-wysihtml5-rails'
gem 'gingerice'
gem 'gvis', '>= 2.0.0'
gem "google_visualr", ">= 2.1"
gem "zendesk_api"
gem "oink"
gem 'rubyzip', '1.0.0'
gem "zip-zip"
gem 's3_swf_upload'
group :assets do
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem 'less-rails-bootstrap'
gem 'less'
end
gem "twitter-bootstrap-rails" # don't put in assets group for some stupid reason.
gem 'font-awesome-rails'
gem 'rabl'
gem 'gon'
gem 'versioncake', :git => 'git://github.com/bwillis/versioncake.git', :branch => 'master'
gem "oauth-plugin", "~> 0.5.1"
# Authentication and authorisation
gem "cancan", '~> 1.6.7'
gem "devise" #, "~> 1.4.8"
gem 'devise_invitable', '~> 1.0.0'
# Barcodes
gem 'barby' #for generating barcodes
gem 'chunky_png' #for turning barcodes into png
# Forms
gem 'formtastic'
gem 'twitter_bootstrap_form_for'
gem 'client_side_validations', :git => "git://github.com/bcardarella/client_side_validations.git"
gem 'client_side_validations-formtastic'
gem 'cocoon' #adds link_to_add_association functionality in forms, so you can add nested fields using JS. https://github.com/nathanvda/cocoon
gem 'letsrate'
gem 'formtastic-bootstrap', " ~> 2.0.0"
gem 'active_link_to'
# Search
gem "ransack" #:git => "git://github.com/ernie/ransack.git"
gem 'pg_search', "0.7.0"
gem 'ancestry'
# IO
gem "activerecord-import" #used in one off class methods for importing. Provides the .import method.
gem "csv_builder"
gem 'pdfkit'
gem 'wkhtmltopdf'
gem "rmagick"
gem 'paperclip', '~> 2.3'
gem 'paperclip-meta' # extends function of paperclip gem: saves default thumbnail image size info in appropriate table
gem "googlebooks"
gem "amazon-ecs"
gem 'acts_as_xlsx'
gem "prawn", "~> 1.0.0.rc2"
gem 'activemodel-warnings'
gem "roo", "~> 1.11.2"
# Other
gem 'deep_cloneable', '~> 1.5.2'
gem "isbn"
gem 'wicked', '~> 0.5.0' #upgrade problem
gem "strip_attributes", "~> 1.2"
gem "microformats_helper"
gem "sanitize"
gem 'paper_trail', '~> 2'
gem "best_in_place"
gem 'shortener'
gem 'twitter'
gem 'acts-as-taggable-on', "~> 2.3.3" #upgrade problem
gem 'simple_calendar'
gem "yard" # yard server --reload for a server running on 8808
# Rails 3.1 - Asset Pipeline
gem 'json'
gem 'coffee-script'
gem 'sprockets-image_compressor', "~> 0.2.0"
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'yui-compressor'
gem 'compass-rails'
end
# Rails 3.1 - Heroku
gem 'pg', "=0.16.0"
gem 'dalli'
gem 'memcachier'
gem 'seed_dump' # e.g. bundle exec rake db:seed:dump MODELS=ValidationTest,Book
gem "figaro"
group(:development, :test) do
gem 'simplecov', :require => false
gem 'ruby-prof'
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git' # run with bundle exec annotate
gem "rails-erd" # for creaating erd diagrams. Run with rake erd
gem 'autotest'
gem 'autotest-rails'
gem 'ZenTest', '4.5.0'
gem 'factory_girl', "~> 3.0.0"
gem 'factory_girl_rails'
gem 'faker', '0.3.1', :require => false
gem 'launchy'
gem 'rspec'
gem 'rspec-core', :require => 'rspec/core'
gem 'rspec-expectations', :require => 'rspec/expectations'
gem 'rspec-mocks', :require => 'rspec/mocks'
gem 'rspec-rails'
gem 'selenium-webdriver', '2.5.0'
gem 'capybara'
gem "fakes3"
end
gem 'lazy_high_charts'
gem 'bullet', group: :development
Some gems have problem installing in parallel, these should be reported to bundler/bundler like this one https://github.com/bundler/bundler/issues/2813
In this Gemfile this is the problem line:
gem 'formtastic-bootstrap', " ~> 2.0.0"
Change to
gem 'formtastic-bootstrap', "2.1.3"
And it works. This is how I found it:
Install bundler latest $ gem install bundler
Then run $ bundle install -j4 this will try to install up to 4 gems in parallel.
When it fails with this error message
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/Users/schneems/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.5.1/lib/bundler/parallel_workers/worker.rb:33:in `pop': No live threads left. Deadlock? (fatal)
Find a Gem not checked out by running
$ bundle list
Could not find gem 'formtastic-bootstrap (~> 2.0.0) ruby' in the gems available on this machine.
Comment out that line in your Gemfile and repeat until your whole Gemfile installs. Once it installs gradually add back in the ones you commented. Likely a later version of a Gem will be able to fix the problem.

Problems with sprockets when deploying Rails 3.1.rc4

I'm sure that I am just overlooking something simple here but this has been driving me crazy all night! When trying to deploy a Rails 3.1.rc4 application to the Cedar stack on Heroku (I did this successfully a month ago with a similar Gemfile) I am receiving this error:
Could not find sprockets-2.0.0.beta.10 in any of the sources
My Gemfile looks like this:
source 'http://rubygems.org'
# Core
gem 'rails', '3.1.0.rc4'
# Asset template engines
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'uglifier'
# Misc
gem 'devise'
gem 'jquery-rails'
gem 'omniauth'
gem 'fb_graph'
gem 'compass', git: 'https://github.com/chriseppstein/compass.git', branch: 'rails31'
gem 'haml'
gem 'cancan'
gem 'kaminari'
gem 'friendly_id', '~> 3.3.0', git: 'https://github.com/norman/friendly_id.git'
gem 'recaptcha', :require => 'recaptcha/rails'
gem 'aws-ses', '~> 0.4.3', :require => 'aws/ses'
# Local Environment
group :test do
# Pretty printed test output
gem 'turn', :require => false
gem 'sqlite3'
end
# Heroku Environment
group :production do
gem 'pg'
gem 'execjs'
gem 'therubyracer'
end
After searching around and finding this article on Google Groups, I determined that this must be fixable by adding this line
gem 'sprockets', '2.0.0.beta10'
to my Gemfile and then running
bundle update sprockets
This failed with
Could not find gem 'sprockets (= 2.0.0.beta10, runtime)' in any of the gem sources listed in your Gemfile.
and at this point I don't know what to do or how to handle this. Is it possible that I need to upgrade to Rails 3.1.rc5 and if so how may I do that without starting over from scratch?
Thank you for any help that you can provide!
-Robert
Just bump your rails version up to rc5
gem 'rails', '3.1.0rc5'
then:
bundle update

Resources