I got error when I run bundle install - ruby

I typed rails s to run my server then I got this:
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
Could not find gem 'pg' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
So I did bundle install then I got this:
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
I did brew install postgres to solve this but it still didn't work. Also I put 'gem pg '0.18.4' on Gemfile then did bundle install but still didn't work.
I need your help!
below is my Gemfile
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', group: [:development, :test]
gem 'pg', group: :production
#gem 'pg', '0.18.4'
gem 'rails_12factor', group: :production
# 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'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

Have you tried to clean and rebuild you gem bundle? You can do it with command bundle clean --force and then bundle install again.
Please be advised: the clean command will remove all your gems.
Post back the result of such commands if you decide to run them.

Related

ArgumentError: pathname contains null byte - prawn - docker

I'm currently working on a Rails 5.2 application. In the Dockerfile I'm using ruby:2.5-alpine. when running the following code
pdf_attached_doc.image signature_image I get the following error.
ArgumentError: pathname contains null byte
from /usr/local/bundle/gems/prawn-2.2.2/lib/prawn/images.rb:148:in `initialize'
I tried brew prune and brew update without success. Here is my Dockerfile
FROM ruby:2.5-alpine
# Bare minimum dependencies for our Rails App with the Apline image;
# build-base, git, nodejs, linux-headers, postgresql-dev, tzdata
#
# Project dependencies include;
# pdftk
RUN apk add --no-cache --update \
bash \
build-base \
git \
nodejs \
pdftk \
postgresql-dev \
tzdata \
less
# Set the working directory for all commands after this
WORKDIR /app
# Bundle the application
# Copy our Gemfiles into the app directory and install
ADD ./rails_app/Gemfile \
./rails_app/Gemfile.lock \
/app/
RUN bundle install
Here is my Gemfile
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use postgresql as the database for Active Record
gem 'pg'
# Loads environment variables from `.env`.
gem 'dotenv-rails', groups: %i[development test]
# 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
# For svg sprites
gem 'svgeez', '~> 1.0', '>= 1.0.3'
# Interact with Box API via Boxr Ruby library.
gem 'boxr'
# 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'
# jquery-rails
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
# PDF merger
gem 'combine_pdf', '~> 1.0', '>= 1.0.14'
# PDF parse into form
gem 'pdf-forms', '~> 1.1', '>= 1.1.1'
# Add PNG, JPEG and Other images to PDF
gem 'prawn', '~> 2.1'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Parse address
# Use httparty for requests
gem 'httparty', '~> 0.16.2'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
gem 'pry-rails', group: :development
# 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
gem 'byebug', platforms: %i[mri mingw x64_mingw]
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application running
# in the background. Read more: https://github.com/rails/spring
gem 'rubocop', '~> 0.59.1', require: false
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', '< 4.0'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
Any help?
I don't understand docker with proficiency. But, all times that i had this error with ruby, is because on the situation i'ved been send a file in verification. The solution for those issues are send the file path instead the file.

bundle install: 'minitest/autorun x64-mingw32' not in Gemfile

When trying to run bundle install on i receive the following exception:
$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Could not find gem 'minitest/autorun x64-mingw32' in any of the gem sources
listed in your Gemfile.
I was originally trying to run bundle exec rake, which suggests the same issue with gem 'minitest/autorun x64-mingw32'. Running them with rake test works fine; hence, I think I've done something wrong with bundler related to my OS (windows 7 x64). The install works properly without this package. I also tried using unit/test with the same result.
Ruby version is 2.4.4.
Gemfile:
source "https://rubygems.org"
gemspec
gem 'json', '~> 2.1.0', '>= 2.0.4'
gem 'addressable', '~> 2.5.2', '>= 2.5.2'
gem 'mongo', '~> 2.5.1', '>= 2.5.1'
group :test do
gem 'rake'
gem 'minitest/autorun'
end
Do I need to specify the platform or some other variable so that bundle looks for the right version of the gem on rubygems?
Any help would be much appreciated.

Is there a way to "gem install" to only the development environment, or test?

Using gem install, how can I add a gem to only one particular environment, like development or test or production? As seen below:
group :development do
gem 'web-console', '>= 3.3.0'
end
You can't do this via gem as the Gemfile is used by Bundler. However, since Bundler version 1.15.0 you can use bundle add:
bundle add web-console --group development
This will then add the following line to your Gemfile:
gem "web-console", "~> 3.6", :group => [:development]

Confusion on how the bundler's group works

I'm using ruby 1.9.3p194 and bundler 1.1.4
In my Gemfile I have this:
group :production do
gem 'thin', '1.4.1'
end
When I run $ rails s, bundler keeps complains:
Could not find gem 'thin (>= 1.4.1) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
I'm running under development environment, so shouldn't it NOT care if it is installed or not? Dose bundler force you to install ALL the gems when running $ rails s?
I also tried the group:test, same thing happens. That doesn't really make sense to me, can anyone help?
my gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'mysql2'
# 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'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :production do
gem 'thin', '1.4.1'
end
gem 'devise', '2.1.2'
gem 'cancan', '1.6.8'
gem 'will_paginate', '3.0.3'
Possibly the problem is that you are running rails s, while you need to run bundle exec rails s. If you precede a command with bundle exec, it is executed within the context of the bundle. All the gems available to bundler are then available to the command.
By default, gems from bundles are installed in the global gem directory. This can produce confusing results when you don't prepend bundle exec to a command: imagine you have both rails 3.1 and rails 3.2 in your global gems and your Gemfile mentions 3.1. Then you will still call the executable from rails 3.2 when you simply say rails on the command line.
Now of course thin could only be missing if it wasn't installed with the global gems. Assuming you've used the --path option to bundler at least once, your gems have been installed to the path specified there and not to the global repository. After using --path, you must specify bundle exec, otherwise gems simply won't be found at all.

Ruby Guard questions - 'Please install the sqlite3 adapter' - railstutorial.org

I am following along the Ruby on Rails Tutorial and have gotten somewhat confused in the testing section, in particular - 3.6.2 - Automated tests with Guard
As per the tutorial's instructions for deployment to Heroku, I've switched over to Postgresql and removed sqlite3 from my gemfile and did a bundle install to update.
However, once I run
bundle exec guard
I receive the message:
/Users/username/.rvm/gems/ruby-1.9.3-p125#global/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:147:in block in replace_gem': Please install the sqlite3 adapter:gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.) (LoadError)
I'm confused why I need this as sqlite3 has been removed from my environment?
My Gemfile is as follows:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'pg', '0.12.2'
group :development, :test do
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'rspec-rails', '2.9.0'
gem 'capybara', '1.1.2'
gem 'rb-fsevent', :require => false
gem 'growl', '1.0.3'
gem 'spork', '0.9.0'
end
I'm a bit confused because the Gemfile in the tutorial shows sqlite3 again even though it was removed in the previous section of the tutorial.
Update your database config file to use postgresql adapter:
adapter: postgresql
encoding: unicode
database:
username:
password:

Resources