I am trying to build a docker container but getting the following error message:
Step 8/12 : RUN bundle binstubs bundler --force
---> Running in ed94b127974b
Could not find gem 'rails (>= 5.1.5, ~> 5.1)' in any of the gem sources listed
in your Gemfile.
ERROR: Service 'dockerzon' failed to build: The command '/bin/sh -c bundle binstubs bundler --force' returned a non-zero code: 7
I have tried with different versions of rails in my Gemfile with no success! This is what I have in my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
# gem 'rails', '4.2.6'
# gem 'rails', '>= 5.1.5'
gem 'rails', '~> 5.1', '>= 5.1.5'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.7'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 4.1.6'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2.2'
# 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.7'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 1.0.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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 3.5.1'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'pg', '~> 1.0.0'
gem 'redis-rails', '~> 5.0.2'
gem 'sidekiq', '~> 5.1.1'
gem 'puma', '~> 3.11.2'
gem 'rack-timeout', '~> 0.4.2'
and this is my Dockerfile:
# Use the barebones version of Ruby 2.5
FROM ruby:2.5-slim
# Optionally set a maintainer name to let people know who made this image.
# Install dependencies:
# - build-essential: To ensure certain gems can be compiled
# - nodejs: Compile assets
# - libpq-dev: Communicate with postgres through the postgres gem
RUN apt-get update && apt-get install -qq -y --no-install-recommends \
build-essential nodejs libpq-dev
# Set an environment variable to store where the app is installed to inside
# of the Docker image. The name matches the project name out of convention only.
ENV INSTALL_PATH /dockerzon
RUN mkdir -p $INSTALL_PATH
# This sets the context of where commands will be ran in and is documented
# on Docker's website extensively.
WORKDIR $INSTALL_PATH
# Ensure gems are cached and only get updated when they change. This will
# drastically increase build times when your gems do not change.
COPY Gemfile Gemfile
# We want binstubs to be available so we can directly call sidekiq and
# potentially other binaries as command overrides without depending on
# bundle exec.
# RUN bundle install --binstubs
RUN bundle binstubs bundler --force
# Copy in the application code from your work station at the current directory
# over to the working directory.
COPY . .
# Provide a dummy DATABASE_URL to Rails so it can pre-compile assets.
RUN bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass#127.0.0.1/dbname SECRET_TOKEN=dummytoken assets:precompile
# Ensure the static assets are exposed through a volume so that nginx can read
# in these values later.
VOLUME ["$INSTALL_PATH/public"]
# The default command that gets ran will be to start the Puma server.
CMD bundle exec puma -C config/puma.rb
Try to update the version of your RubyGems:
gem update --system
Then change the line in Gemfile to:
gem 'rails', '~> 5.1.5'
Now run bundler to install the gems:
bundle install
Add below lines in your Dockerfile
RUN gem install rails
ruby:2.5-slim this docker image doesn't contain rails. It only contains ruby. You can't install rails using Gemfile. You have to install rails before bundling your gemfile.
Related
Here is the Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.0'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Flexible authentication solution for Rails with Warden
gem 'devise', '~> 4.7'
# A simple HTTP and REST client
gem 'rest-client', '~> 2.1'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
# Devise supports i18n in controllers, models, and in other areas,
# but it does not have support for internationalized views.
# devise-i18n adds this support.
gem 'devise-i18n', '~> 1.9'
# Devise Bootstrap Views
gem 'devise-bootstrap-views', '~> 1.0'
# Configure Devise to send its emails asynchronously using ActiveJob
gem 'devise-async', '~> 1.0'
# Stripe is the easiest way to accept payments online
gem 'stripe', '~> 5.22'
# A gem that provides a client interface for the Sentry error logger
gem 'sentry-raven', '~> 3.0'
# Taming Rails' Default Request Logging
gem 'lograge', '~> 0.11'
# Ruby state machines
gem 'aasm', '~> 5.0'
# Allows to use ActiveRecord transactional callbacks outside of ActiveRecord models, literally everywhere in your application.
gem 'after_commit_everywhere', '~> 0.1', '>= 0.1.5'
# Agnostic pagination in plain ruby
gem 'pagy', '~> 3.8'
# Connection Pool
gem 'connection_pool', '~> 2.2'
# Redis client
gem 'hiredis', '~> 0.6'
gem 'redis', '~> 4.1', require: ['redis', 'redis/connection/hiredis']
# Sidekiq
gem 'sidekiq', '~> 6.0'
# Check password strength against several rules
gem 'password_strength', '~> 1.1'
# Slack Ruby Client
gem 'slack-ruby-client', '~> 0.15'
# Assets on AWS S3/CloudFront
gem 'asset_sync', '~> 2.12'
gem 'fog-aws', '~> 3.6'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0'
gem 'rspec-rails', '~> 4.0'
gem 'amazing_print', '~> 1.2'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'capybara-screenshot'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
gem 'factory_bot_rails', '~> 6.0'
gem 'shoulda-matchers', '~> 4.1'
gem 'rails-controller-testing'
gem 'faker'
gem 'database_cleaner-active_record'
gem 'coderay'
gem 'mock_redis'
end
The application seems to be blocked during Rails.application.initialize!.
I wonder if it could be a gem that is not compatible with Ruby 3.0, but I started a new app from scratch, installed all the gems and the app started normally.
I'm using puma (5.1.1) as web server.
The app is running in docker container via docker-compose.
FROM ruby:2.7.2
# Update for security reason
RUN apt-get update -yqq && apt-get upgrade -yqq -o Dpkg::Options::="--force-confold" && apt-get install -yqq --no-install-recommends \
vim # needed for editing rails credentials
# Ensure we install an up-to-date version of Node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
# Ensure latest packages for Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
nodejs \
yarn
ENV RAILS_ROOT /var/www/app
RUN mkdir -p $RAILS_ROOT
COPY Gemfile* /var/www/app/
WORKDIR /var/www/app
ENV BUNDLE_PATH /gems
RUN bundle install
COPY package.json package.json
COPY yarn.lock yarn.lock
RUN yarn install --check-files
COPY . /var/www/app/
EXPOSE 3000
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT ["./puma-entrypoint.sh"]
CMD ["bundle", "exec", "puma", "-C", "config/puma/development.rb"]
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
Is there a way to have logs to see what is happening during boot process?
Please give more information.
On which system are you?
How do you start your application? If you get in trouble, start it always on console.
Puma has a log output. Search for this location. Put log output here.
Try to remove all gems or big part of it to find error.
Researching for this topic, I realized that there isn't much useful information, so just trying to contribute for this cause...
You don't give too much information, but try again changing FROM ruby:2.7.2 to FROM ruby: 3.0.0 in your Dockerfile. Also check that Bundler is still working with ruby 3.0, if it's not, try updating this to v2.2.
https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
https://bundler.io/blog/
Error when running rails docker container with volumes
bundler: failed to load command: rails (/usr/local/bundle/bin/rails)
Bundler::GemNotFound: Could not find rake-12.3.2 in any of the sources
I am able to run my rails docker container without volume.
But when i attach volume as such:
docker run --name rails-chat-tutorial-web \
-e DATABASE_HOST=172.17.0.1 \
-e DATABASE_PORT=5432 \
-e DATABASE_USERNAME=postgres \
-e DATABASE_PASSWORD=postgres \
-e REDIS_URL=redis://172.17.0.1:6379/1 \
-p 3000:3000 \
-v $(pwd):/application rails-chat-tutorial
I will get this error output:
bundler: failed to load command: rails (/usr/local/bundle/bin/rails)
Bundler::GemNotFound: Could not find rake-12.3.2 in any of the sources
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/spec_set.rb:87:in `block in materialize'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `map!'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `materialize'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/definition.rb:170:in `specs'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/definition.rb:237:in `specs_for'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/definition.rb:226:in `requested_specs'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/runtime.rb:108:in `block in definition_method'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/runtime.rb:20:in `setup'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler.rb:107:in `setup'
/usr/local/bundle/gems/bundler-2.0.1/lib/bundler/setup.rb:20:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
I have tried including these lines in my Dockerfile but still get the error:
RUN gem install rake -v '12.3.2'
RUN bundle install --binstubs
RUN bundle install --path vendor/bundle
RUN bundle install --local
RUN bun
dle install --local --path=vendor/cache
This is my Dockerfile:
FROM ruby:2.5.0-stretch
COPY ./Gemfile ./application/
COPY ./Gemfile.lock ./application/
WORKDIR /application
ENV BUNDLER_VERSION 2.0.1
RUN gem install bundler -v '2.0.1'
RUN bundle install --deployment --without development test
RUN apt-get update -qq && apt-get install -y build-essential
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN bundle install --local --path=vendor/cache
RUN npm install yarn -g
COPY . .
ENV RAILS_ENV production
ENV SECRET_KEY_BASE production_test_key rails c
RUN bundle exec rake assets:precompile
EXPOSE 3000
CMD bundle exec rails server
Content of Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
group :production do
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'devise'
gem 'bootstrap', '~> 4.3.1'
gem 'jquery-rails'
gem 'simple_form'
gem 'redis'
gem 'httparty', '~> 0.17.0'
gem 'rake', '12.3.2'
If I run the rails container with shell and gem list, i get 'rake (12.3.2, 12.3.0)'
I have been on this for the past 2 days but no progress.
Thank you in advance for those who are able to provide some guidance.
When you add a docker run -v $(pwd):/application option, it hides everything in the /application directory in the image and replaces it with the content from your host system. That in particular includes the /application/vendor directory: any bundle commands in your Dockerfile are completely ignored, and your host system's ./vendor directory gets used instead.
There's not really a good answer to this, if you must have live editing and reloading in your deployed container. The Node ecosystem is similar (third-party libraries are in ./node_modules) and most similar questions are about Node rather than Ruby. Add a volume to Docker, but exclude a sub-folder suggests adding an anonymous volume for ./vendor; the first time only that you run your application it will get populated from the image, but if you later change your Gemfile it won't get updated and replicating this setup is unnecessarily complicated in cluster environments like Kubernetes.
If you want to try the anonymous-volume path, that could look like
docker run --name rails-chat-tutorial-web ... \
-v $PWD:/application -v /application/vendor \
rails-chat-tutorial
$EDITOR Gemfile
bundle install
docker stop rails-chat-tutorial-web
docker rm -v rails-chat-tutorial-web
docker run ...
(docker rm -v will delete the anonymous volume, and it will get recreated on the next docker run with updated contents. You've told Docker that directory contains important non-code data that must be preserved across runs.)
The sequence that's worked well for me is to develop my application in total ignorance of Docker: develop it locally, run it, write good rspec tests, and generally believe it works. Only then do I docker build and docker run an image, without bind-mounting my source code into it. If it breaks then I reproduce the issue on my local development environment, write a test for it, and fix it, then repeat the docker build; docker run sequence.
Good day, today I installed ruby on rails on my server, nevertheless there are errors in execution of my app:
rails new testingApp
cd testingApp
rails server
// Appears in my console(Putty) a error.
The error is:
Could not find gem 'puma (~> 3.7)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
I do not understand reason of error and I need help regarding this.
I learned to installing Ruby and complements from youtube:
https://youtu.be/ml_-nWq0LEg
The command used for installing there are:
Ruby installation: sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev libsqlite3-dev
Rails installation: sudo gem install rails –v 5.0.0.1
NodeJS installation: sudo apt-get install nodejs
My server have technical requirements:
Ubuntu 16.04.
256 mb of ram.
0.5 Core.
Sorry for my english is very bad.
Thanks for reading of my post and help.
If you project created after putting the command
rails new testingApp
then it is ok but need to install all dependencies
cd testingApp
#=> then run bundler
bundle install
#=> if bundle run properly then run
rails server or rails s
Hope will work
You probably need to install the gem sources listed in Gemfile.
$ cat Gemfile
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
Please run bundle install --path vendor/bundle to install these gems.
and run bundle exec rails server to start rails on those dependencies.
I'm trying to learn Ruby on Rails.
Currently been trying out Rails framework. I've installed it. Create new project in MyBlog folder, but when I try to run:
rails server
I get back an error:
Could not find gem 'rails (= 4.2.5) x86-mingw32' in any of the gem sources listed in your Gemfile or available on this machine. Run `bundle install` to install missing gems.
I've installed bundle as suggested. Had few problems with installing it as well, but I've found a soultion on the internet.
Before bundle install I was getting another error saying that it could not find gem 'sqlite3'
Did someone had similar problem? Can you help me with solving it?
Update:
Content of my Gemfile is:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# 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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Errors when try to run 'bundle install':
Try to install the following packages to succeed bundle install
sudo apt-get install build-essential
sudo apt-get install libgmp3-dev
These packages are for Linux environment. Find the alternatives for other environments. Let me know if you got any error.
open file Gemfile.lock, find and delete "x64-mingw32" then run the command:-
$bundle install
Late answer but this happened to me just now.
What worked for me was figuring out I accidently installed an older Ruby version.
In your last screenshot you received a line:
Make sure that `gem install json -v '1.8.3'` succeeds before bundling
This command probably failed due to an older Ruby version, get the latest version here (Assuming you're a windows user) https://rubyinstaller.org/downloads/
P.S
Make sure you remove any previous Ruby / Rails installations.
What you need is a "With DEVKIT" installer, preferably the one they recommend on (starts with "=>").
After creating a Ruby on Rails skeleton (before pushing to master and Heroku) and running: bundle install, I sometimes encounter the following error:
An error occurred while installing pg (0.18.2), and Bundler cannot continue
Make sure that gem install pg -v '0.18.2' succeeds before bundling.
The following command remediates the issue altogether: bundle install --without production.
Why exactly does the aforementioned command remediate the issue? As I understand, the command bypasses production environment gems for deployment; so, is my understanding correct and why must this be the case? Thank you!
Here is my gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# 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'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development do
gem 'sqlite3'
end
gem 'bootstrap-sass'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# 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 best resource answering the "why" component of this question appears to be explained thusly by Michael Hartl's Ruby on Rails Tutorial:
"Heroku uses the PostgreSQL database...which means that we need to add the pg gem in the production environment to allow Rails to talk to Postgres...Generally speaking, it's a good idea for the development and production environments to match each other as closely as possible, which includes using the same database, however we'll use SQLite locally and PostgreSQL in production."
So, basically it appears that the issue is a matter of maintaining conventions between two different environments- production and development (local)- and more specifically, database types (Postgres vs SQLite), which is why bundle install --without production is required:
"To prepare the system for deployment to production, we run bundle install with a special flag to prevent the local installation of any production gems (which in this case consist of ph and rails_12factor)...Because the only gems added are restricted to a production environment, right now this command doesn't actually install any additional local gems, but it's needed to update Gemfile.lock with the pg and rails_12factor gems."
If the remediation for Heroku deployment bundle install --without production is an acceptable alternative to bundle install, it just seems too bad to be true; if so, is there another setting or file I can revise in order to achieve the same results effected by the regular bundle install? Thanks!