Gemfile includes incorrect environment - ruby-on-rails

When I do $ bundle install, it attempts to get gems only meant for production, despite me being on development.
I double checked that I'm on development: echo $RAILS_ENV # outputs "development"
Here is a copy of my gem file. If I remove :staging in the last block, then my bundle installs correctly and ignores this group. Why would adding :staging cause my app to include these gems?
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '~> 3.0.1.0.rc'
gem 'bcrypt-ruby', '3.0.1'
# generates names, email addresses, and other placeholders for factories.
gem 'faker'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'aws-sdk', '1.11.1'
gem 'd3-rails', '~>3.3.7'
# used for file ajax uploads
gem 'remotipart', '~> 1.2'
# used for making server side variables accessible in JS
gem "iconv", "~> 1.0.4"
gem "roo", "~> 1.13.2"
gem 'underscore-rails'
gem 'gon', '4.1.0'
# gem "introjs-rails"
# High voltage for static pages
gem 'high_voltage', '~> 2.0.0'
gem "koala", "~> 1.8.0rc1"
gem 'acts_as_list'
gem "bugsnag"
gem 'devise'
# EC2 server is passenger
gem 'passenger'
# easily create seeds
gem 'seed_dump'
#add crossfilter for exploring high dimensional datasets and dcjs for charts
gem 'crossfilter-rails'
# gem 'dcjs-rails'
gem 'activeadmin', github: 'gregbell/active_admin'
# Monitor site speed.
gem 'newrelic_rpm'
group :development, :test do
gem 'sqlite3', '1.3.8'
# rspec-rails includes RSpec itself in a wrapper to make it play nicely with Rails.
gem 'rspec-rails'
# replaces Rails' default fixtures for feeding test data to the test suite with much more preferable factories
gem 'factory_girl_rails'
# watches your application and tests and runs specs for you automatically when it detects changes.
gem 'guard-rspec'
end
group :test do
# runs a browser
gem 'selenium-webdriver'
# makes it easy to programatically simulate your users' interactions with your application
gem 'capybara'
# Shows growl notifications (os x only)
gem 'growl'
# opens your default web browser upon failed integration specs to show you what your application is rendering.
gem 'launchy' # tims tutorial
# helps clear out db after using selenium in tests
gem 'database_cleaner' # tims tutorial
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
# fuck turbolinks.
# gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
# added for resizing panes on d3fiddle pages
gem 'jquery-ui-rails'
# added for code highlighting on d3fiddle pages
gem 'codemirror-rails'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production, :staging do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end

Use bundle install --without staging production.You can find more information about bundle here.
Update:
It is because of Bundler.require(:default, Rails.env) present in config/application.rb that bundle does not install gems present in test and production by default.

Related

Rails 'bundle install' fails because attempt to write to file 'is unsupported by your OS'

I'm attempting to run a rails app on my local machine developed elsewhere, but I can't get it to run locally. When I run rails s to get the server running, I get:
Could not find proper version of railties (4.2.6) in any of the sources
Run `bundle install` to install missing gems.
So, naturally, I run bundle install but get the error:
Attempting to write to
`/home/rails/apps/intranet/shared/bundle/ruby/2.2.0` is
unsupported by your OS
My OS is macOS Sierra version 10.12.4.
Also, railties is in the gem folder and seems to be the correct version.
Thanks in advance.
Edit: Adding Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'devise'
gem 'rails_admin'
gem 'carrierwave'
gem 'where-or'
# Railties
gem 'railties', '~> 4.2', '>= 4.2.6'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'pry-rails'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'guard', require: false
gem 'guard-rspec', require: false
gem 'guard-bundler', require: false
gem "guard-cucumber", require: false
gem 'ruby_gntp'
gem 'terminal-notifier'
gem 'terminal-notifier-guard'
gem 'thin'
gem 'quiet_assets'
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano3-unicorn'
gem 'capistrano-bundler'
gem 'better_errors'
gem 'binding_of_caller'
end
group :test do
gem 'database_cleaner'
gem 'capybara'
gem 'shoulda-matchers'
gem 'poltergeist'
gem 'launchy'
gem "cucumber-rails", require: false
end
Found out what was the issue. Since this was downloaded from a remote server, the .bundle/config file had a different path for 'BUNDLE_PATH'. I simply had to change that to the path on my own computer instead of the path on the remote server and I stopped getting the error.
check if you have write permissions to the directory /home/rails/apps/intranet/shared/bundle/ruby/2.2.0`

Rake Assets Precompile without Gems in Development or Test Groups

Okay, so I've got an error while building my Docker image (think of it as similar to a deploy step, or Heroku deploy if you're unfamiliar with Docker).
Gems that are in the :test and :development groups are being looked for when the precompile step happens, and since I've bundled --without development test - as I don't want to have QT just so that capybara-webkit doesn't error on bundle - the precompile step is throwing an error.
The error is always a variant of:
Could not find <gem-name> in any of the sources (Bundler::GemNotFound)
My Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.9'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
gem 'unicorn', '~> 4.8.3'
gem 'unicorn-worker-killer', '~> 0.4.2'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'rdf', '~> 1.1.0'
gem 'tripod', '~> 0.11.1'
gem 'devise'
gem 'devise_invitable'
gem 'authority'
gem 'mongoid', '~> 4.0.0'
gem 'bootstrap-sass', '~> 3.3.3'
# pagination
gem 'kaminari', '~> 0.16.3'
gem 'bootstrap-kaminari-views'
# background processing
gem 'sidekiq'
gem 'sidekiq-status'
gem 'request_store', '~> 1.1.0'
# add memoization
gem 'memoist', '~> 0.12.0'
# dropbox gem for uploads etc
gem 'dropbox-sdk', '~> 1.6.4'
# error reporting
gem 'sentry-raven'
group :development, :test do
gem "rspec-rails", "~> 3.0.0"
gem "factory_girl_rails", "~> 4.5.0"
gem "capybara", "~> 2.4"
gem "database_cleaner"
# gem "selenium-webdriver"
gem 'poltergeist'
gem 'capybara-webkit'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
#gem 'byebug'
gem 'pry-byebug'
gem 'better_errors', '~> 2.1.1'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
# gem 'spring'
end
The line in the Dockerfile where the error happens is:
RUN /bin/bash -l -c "RAILS_ENV=production bundle exec rake assets:precompile RAILS_GROUPS=assets --trace"
So basically, what I'm really after is the equivalent for --without test development for the rake task. Can I do that? As per some advice, I've already changed (in application.rb):
Bundler.require(*Rails.groups)
to
Bundler.require(:default, :assets, Rails.env)
Anybody have Rails-fu enough to solve this one? I've looked in the docs and on SO, as well as asking my colleagues but I'm still banging my head against the wall over this.
bundle install --path vendor/cache
Try this and let me know if it doesn't work!

how to fix ruby bundle install error?

Everytime I try to run bundle install inside a local copy of this RoR project directory, I get an error. I have rvm installed with ruby 2.1.2 and 2.2.2, rails is installed as well. I am running via vagrant on this box, Ubuntu 14.04 with 1gb of ram tho I don't think any of this is relevant? I can't seem to find the missing file the error is pointing to as well?
Update: Here is the Gemfile
source 'https://rubygems.org'
ruby '2.2.2'
gem 'rails', '~> 4.1.6'
#gem 'catarse_api', path: '~/code/catarse_api'
gem 'catarse_api', github: 'catarse/catarse_api'
gem 'protected_attributes'
gem 'rails-observers'
gem 'sidekiq', '~> 3.1.3'
# Turns every field on a editable one
gem "best_in_place", :git => "git://github.com/bernat/best_in_place", ref: "ee95961e639022e6aa528704b8cb4789596ea61b"
# State machine for attributes on models
gem 'state_machine', require: 'state_machine/core'
# Database and data related
gem 'pg', '0.17.1'
gem 'dbhero', '>= 1.1.6'
gem 'postgres-copy'
gem 'pg_search'
gem 'i18n_alchemy'
gem 'schema_plus'
gem 'chartkick'
gem 'catarse_settings_db', '>= 0.1.0'
# Notifications
gem 'user_notifier', '~> 0.0.5'
# Mixpanel for backend tracking
gem 'mixpanel-ruby'
gem 'mixpanel_client'
# Payment engines
gem 'catarse_moip', '~> 3.2.0'
gem 'catarse_pagarme', '2.6.8'
#gem 'catarse_pagarme', path: '../catarse_pagarme'
# Decorators
gem 'draper'
# Frontend stuff
gem 'slim-rails'
gem 'jquery-rails'
gem 'browser'
gem "cocoon"
# Static pages
gem 'high_voltage'
# Authentication and Authorization
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'devise'
gem 'ezcrypto'
gem 'pundit'
# Email marketing
gem 'catarse_monkeymail', '>= 0.1.6'
# HTML manipulation and formatting
gem 'simple_form'
gem 'mail_form'
gem "auto_html"
gem 'kaminari'
gem 'redactor-rails', github: 'catarse/redactor-rails'
# Uploads
gem 'carrierwave', '~> 0.10.0'
gem "mini_magick"
# Other Tools
gem 'to_xls'
gem 'ranked-model'
gem 'feedjira'
gem 'inherited_resources'
gem 'has_scope', '>= 0.6.0.rc'
gem 'spectator-validates_email', require: 'validates_email'
gem 'video_info', '>= 1.1.1'
gem 'httparty', '~> 0.6.1' # this version is required by moip gem, otherwise payment confirmation will break
# Translations
gem 'http_accept_language'
gem 'routing-filter', '~> 0.4.0.pre'
# Payment
gem 'moip', github: 'catarse/moip-ruby', ref: 'c0225ad71645cd1df35dafa1e45c9f092b3abb9e'
gem 'httpclient', '>= 2.2.5'
group :production do
# Gem used to handle image uploading
gem 'fog', '>= 1.3.1'
# Workers, forks and all that jazz
gem 'unicorn'
# Enabling Gzip on Heroku
# If you don't use Heroku, please comment the line below.
gem 'heroku-deflater', '>= 0.4.1'
# Make heroku serve static assets and loggin with stdout
#gem 'rails_on_heroku'
gem 'rails_12factor'
# Monitoring with the new new relic
gem 'newrelic_rpm'
# Using dalli and memcachier have not presented significative performance gains
# Probably this is due to our pattern of cache usage
# + the lack of concurrent procs in our deploy
#gem 'memcachier'
#gem 'dalli'
end
group :development do
gem "letter_opener"
gem 'foreman'
gem 'better_errors'
gem 'binding_of_caller'
gem 'thin'
# Uncomment only for optimization, should be commented on master branch
# gem 'rack-mini-profiler'
# gem 'ruby-prof'
end
group :test, :development do
gem 'rspec-rails', '~> 3.1'
gem 'rspec-mocks'
gem 'rspec-its'
gem 'rspec-collection_matchers'
gem 'pry'
gem 'jasmine-rails'
end
group :test do
gem 'zonebie'
gem 'fakeweb'
gem 'poltergeist'
gem 'launchy'
gem 'database_cleaner'
gem 'shoulda'
gem 'factory_girl_rails'
gem 'capybara', '~> 2.2.0'
gem 'selenium-webdriver'
end
gem 'sass-rails'
gem 'coffee-rails'
gem 'compass-rails'
gem 'uglifier'
gem 'compass-960-plugin'
gem 'sprockets'
# FIXME: Not-anymore-on-development
# Gems that are with 1 or more years on the vacuum
gem 'weekdays'
ps: please point out any relevant info i should provide as well to help determine the cause.
Apparently there was an issue with bundler, here's how this worked out for me:
cleanup by running gem cleanup bundler
reinstall bundler via gem install bundler

Bundle Install on dev giving an error that a production gem is missing

Why is my gemfile not skipping over "production" gems?
I just installed Rails on Mac OS X Mavericks (possibly an irrelevant detail). When I do bundle install, it gives me an error about missing pg gem. However this is only listed in my production environment, so shouldn't it be skipped? Commenting out my gem pg makes bundle install successful.
Extra context:
I just installed Rails on Mac OS X Mavericks. When I try to open my project, it seems to think I'm in "production" and tries to use my "pg" gem for Postgres. If I try to use rails s or rails console, I get the error that I haven't installed "pg" which should only be used in production for my DB.
I followed this tutorial: http://railsapps.github.io/installrubyonrails-mac.html
My gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '~> 3.0.1.0.rc'
gem 'bcrypt-ruby', '3.0.1'
# generates names, email addresses, and other placeholders for factories.
gem 'faker'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'aws-sdk', '1.11.1'
gem 'd3-rails', '~>3.3.7'
# used for file ajax uploads
gem 'remotipart', '~> 1.2'
# used for making server side variables accessible in JS
gem 'gon', '4.1.1'
gem "introjs-rails"
# High voltage for static pages
gem 'high_voltage', '~> 2.0.0'
gem "koala", "~> 1.8.0rc1"
gem 'acts_as_list'
group :development, :test do
gem 'sqlite3', '1.3.8'
# rspec-rails includes RSpec itself in a wrapper to make it play nicely with Rails.
gem 'rspec-rails'
# replaces Rails' default fixtures for feeding test data to the test suite with much more preferable factories
gem 'factory_girl_rails'
# watches your application and tests and runs specs for you automatically when it detects changes.
gem 'guard-rspec'
gem 'spork-rails', '4.0.0'
gem 'guard-spork', '1.5.0'
gem 'childprocess', '0.3.6'
end
group :test do
gem 'selenium-webdriver'
# makes it easy to programatically simulate your users' interactions with your application
gem 'capybara'
gem 'factory_girl_rails'
gem 'guard-rspec' # tims tutorial
# opens your default web browser upon failed integration specs to show you what your application is rendering.
gem 'launchy' # tims tutorial
# helps clear out db after using selenium in tests
gem 'database_cleaner' # tims tutorial
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
# added for resizing panes on d3fiddle pages
gem 'jquery-ui-rails'
# added for code highlighting on d3fiddle pages
gem 'codemirror-rails'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
gem 'omniauth-facebook', '1.4.0'
By default, Bundler includes all groups. You have to explicitly exclude any groups you don't want like so:
bundle install --without production
After the first time, Bundler will remember your previous setting, so the production group will be excluded next time you run bundle install.

Could not find ZenTest-4.7.0 in any of the sources when running Autotest

When running autotest, I get the error Could not find ZenTest-4.7.0 in any of the sources. After viewing this article, I deleted gemfile.lock, ran 'bundle install', and then tried rerunning autotest. Now I get the error Could not find rake-10.0.3 in any of the sources. FYI, I am using RBENV, and I have no other problems running my app (rails c, rails s, rake, ...). Here is my gem file (btw, both "missing" files appeared in gemfile.lock):
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'rake'
gem 'pg', '0.13.2'
# Sidekiq handles background jobs, using threading
gem 'sidekiq', '>= 2.6.1'
# Need the following gems for sidekiq/web
gem 'slim'
# if you require 'sinatra' you get the DSL extended to Object
gem 'sinatra', :require => nil
gem 'heroku-api' # Need the API for scaling sidekiq
gem 'json'
gem 'premailer'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# Bundle the extra gems:
gem 'mechanize'
gem 'nokogiri'
gem 'spreadsheet'
gem 'xml-simple'
gem 'faker', '~> 0.3.1'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development do
gem 'rspec-rails'
gem 'ruby-debug19'
end
group :test do
gem 'rspec-rails'
gem 'ZenTest'
gem 'shoulda-matchers'
gem 'webrat', '0.7.1'
gem 'factory_girl_rails'
gem 'ruby-debug19'
end
gem 'geoip'
gem 'thin'
gem 'htmlentities'
I'm not 100% certain, but I think you just do:
gem install ZenTest
and probably
gem install autotest-rails
From within your application directory.
These guys are not managed by your gemfile and bundler

Resources