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.
Related
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.
I'm new to Rails. This application works fine on my local machine, and deploys without any problem. But when I run heroku run rake db:migrate, I get this error:
Running `rake db:migrate` attached to terminal... up, run.1269
rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile.
simply adding gem 'pg' to the gemfile didn't work for me.
This worked for me
gem 'pg', '~> 0.20'
Got this answer from
Heroku and Rails: Gem Load Error with Postgres, however it is Specified in GEMFILE
Thanks to Piers C
And yeah, gem 'rails_12factor' helps when it's time view Heroku's logs for error messages.
Add this line to your Gemfile inside the :production group (add one if you don't have it).
group :production do
gem 'pg'
gem 'rails_12factor'
end
It's very clear from the error its self that gem pg needs to be added to your Gemfile. You might be using sqlite3 in your development but Heroku uses postgresql for their database.
Your Gemfile should look like this:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'
gem 'bcrypt-ruby', '3.0.0'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor'
end
I am using ruby 2.3.8. If you are unable to solve this issue, the problem can be with the version of pg you are trying to work with. Replacing gem 'pg' with gem 'pg', '~> 0.21' worked out well for me. Also, This is my database.yml file:
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
development:
<<: *default
database: <%= ENV['DB_NAME'] %>
host: <%= ENV['DB_HOST'] %>
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
reconnect: true
test:
<<: *default
database: <%= ENV['POSTGRES_DB'] %>
password: <%= ENV['POSTGRES_PASSWORD'] %>
username: <%= ENV['POSTGRES_USER'] %>
host: <%= ENV['POSTGRES_HOST'] %>
port: <%= ENV['POSTGRES_PORT'] %>
min_messages: notice
production:
<<: *default
host: <%= ENV['DB_HOST'] %>
database: <%= ENV['DB'] %>
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
And this is my gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use postgresql as the database for Active Record
# Adding pg gem for postgres
gem 'pg', '~> 0.21'
# 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:
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'
# 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
I got the error when upgrading gitlab. I executed the wrong command, saying sudo -u git -H bundle install --without postgres development test --deployment instead of sudo -u git -H bundle install --without mysql development test --deployment
Simply executing
sudo -u git -H bundle install --with postgres did it for me, in your case probably
bundle install --with postgres and afterwards the db migration,
heroku run rake db:migrate
You can also fix it by upgrading rails to a >= 5.1.5 version.
Reference: https://github.com/rails/rails/issues/31673
When I am doing bundle install after adding activeadmin to my gemfile I am getting following errors.
Resolving deltas: 100% (11082/11082), done.
fatal: ambiguous argument 'rails4': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
Git error: command git rev-parse rails4 in directory
/usr/local/rvm/gems/ruby-2.0.0-p247/cache/bundler/git/active_admin- d67faab65e9b74efbc8efb4a777a851e9f78b2ca
has failed.
If this error persists you could try removing the cache directory
'/usr/local/rvm/gems/ruby-2.0.0-p247/cache/bundler/git/active_admin- d67faab65e9b74efbc8efb4a777a851e9f78b2ca'
And my Gemfile is as follows:
source 'https://rubygems.org'
ruby "2.0.0"
gem 'rails', '4.0.0'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.3.0'
gem 'jbuilder', '~> 1.2'
gem 'devise', '3.0.1'
gem 'cancan', '1.6.10'
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~>4.0.0'
gem 'uglifier', '2.1.1'
gem 'pg_search', "~> 0.7.0"
gem 'carrierwave', "~>0.9.0"
gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git'
gem 'bootstrap-sass',
git: 'git://github.com/thomas-mcdonald/bootstrap-sass.git',
branch: '3'
gem 'rmagick'
gem 'mini_magick'
gem 'fog'
gem 'carrierwave_direct'
gem 'sidekiq'
gem 'activeadmin', github: 'gregbell/active_admin', branch: 'rails4'
you only need the following, get rid of the branch "..."
gem 'activeadmin', github: 'gregbell/active_admin'
I think the problem is on following line
gem 'activeadmin', github: 'gregbell/active_admin', branch: 'rails4'
so read the instruction on https://github.com/gregbell/active_admin
I installed zurb-foundation and sass using the steps on their getting started page e.g.
[sudo] gem install compass
cd path/to/where-you-want-your-project
run compass create <project-name> -r zurb-foundation --using foundation
But now I would like to revert back to bootstrap but I am unable to get rid of zurb-foundation from my Padrino project. Even after running gem uninstall zurb-foundation and checking every file in the project for a reference to "zurb" or "foundation" bundler reminds me that zurb is missing and every time I run bundle install it adds it to the project.
What is the best way to remove zurb-foundation from my Padrino app? Thanks
My Gemfile is
source 'https://rubygems.org'
# Distribute your app as a gem
# gemspec
# Server requirements
# gem 'thin' # or mongrel
# gem 'trinidad', :platform => 'jruby'
# Optional JSON codec (faster performance)
# gem 'oj'
# Project requirements
gem 'rake'
# Component requirements
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'sass'
gem 'haml'
gem 'activerecord', '>= 3.1', :require => 'active_record'
gem 'mysql2'
gem 'json'
gem 'annotate'
gem 'compass'
gem 'bootstrap-sass', '~> 2.3.1.2'
# gem 'activerecord-mysql2-adapter'
# Test requirements
gem 'shoulda', :group => 'test'
gem 'rack-test', :require => 'rack/test', :group => 'test'
# Padrino Stable Gem
gem 'padrino', '~> 0.11.1'
#rabl needs to be after padrino
gem 'rabl'
# Or Padrino Edge
# gem 'padrino', :github => 'padrino/padrino-framework'
# Or Individual Gems
# %w(core gen helpers cache mailer admin).each do |g|
# gem 'padrino-' + g, '0.11.1'
# end
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: