error deploying rails app aws elastic beanstalk - ruby-on-rails

I'm using rails 5.00
i keep getting this error when trying to deploy to aws
[Instance: i-04fd37ed6913c4a8a] Command failed on instance. Return
code: 5 Output: (TRUNCATED)...ng uglifier 3.0.2 Installing unf 0.1.4
Installing turbolinks 5.0.1 Installing activesupport 5.0.0.1 An error
occurred while installing nokogiri (1.6.8), and Bundler cannot
continue. Make sure that gem install nokogiri -v '1.6.8' succeeds
before bundling. Hook
/opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed.
For more detail, check /var/log/eb-activity.log using console or EB
CLI.

I ran into the same error "Make sure that gem install nokogiri -v '1.6.8' succeeds before bundling."
It was due to me not selecting the correct deployment version for ruby.
Initially when creating the environment I had left the ruby platform at default which happened to be version 2.3 (Passenger). Got the above error.
I terminated the environment and re-created it but chose ruby 2.2 (Puma) which is what I am using in my development environment.
The AWS environment was created without any errors.
Although the above corrective action fixed the problem, it does not explain why creating a ruby 2.3 (Passenger) environment failed especially since I did a sort of "canned" build - the environment creation was via AWS console using "sample application" in the config. I did not attempt to create it via eb command line or use any of my elasticbeanstalk scripts or deploy my own app.

You have two options to resolve your issue:
1) Add patch to .ebextensions/packages.config like this:
packages:
yum:
patch: []
This would make the yum package manager install it before attempting to bundle install.
2) Add a command config to .ebextensions/nokogiri_command.config like this:
commands:
test:
command: "bundle config build.nokogiri --use-system-libraries"
Either of these two options has worked for me. Don't forget to commit before pushing to AWS.

Related

How can I install Poppler on Heroku for my Rails app?

I wanted to enable previews on PDFs in Active Storage:
https://api.rubyonrails.org/classes/ActiveStorage/Preview.html
In order to do this I installed Poppler on my Mac using brew install poppler. I also installed the Poppler gem in my gemfile. The preview functionality works as I want on my local machine.
When I go to deploy to Heroku the build fails and I get the following error:
An error occurred while installing gobject-introspection (4.0.5), and Bundler
cannot continue.
In Gemfile:
poppler was resolved to 4.0.5, which depends on
gio2 was resolved to 4.0.5, which depends on
gobject-introspection
I've attempted using the following buildpack, but with no luck:
https://github.com/amitree/heroku-buildpack-poppler.git
Has anyone had any success installing Poppler on Heroku? Ideally on more recent Heroku stacks, and not an older stack.

An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue - in rails project

I'm trying to create a project with mysql as a database, ran command
rails new project_name -d mysql
got the following errors
Could not find gem 'mysql2 (~> 0.5)' in locally installed gems. rails importmap:install
Could not find gem 'mysql2 (~> 0.5)' in locally installed gems. Run bundle install to install missing gems.
rails turbo:install stimulus:install Could not find gem 'mysql2 (~> 0.5)' in locally installed gems.
Run bundle install to install missing gems. "
so i ran
bundle install
but it fails and at the end it tells me
An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue
full error https://pastebin.com/jiX7V0Z0
I'm running windows (all answers I found were for linux or mac), any help is appreciated
Edit : as Christos-Angelos Vasilopoulos mentioned, answer in this issue worked https://github.com/brianmario/mysql2/issues/1210#issuecomment-965862944
what I did was the first two steps
1 - Start a cmd terminal and run ridk explicitely by running:
c:\your path to Ruby31-x64\ridk_use\ridk.cmd enable.
This gives you the right environment to do the rest.
2 - From that cmd, run
gem install mysql2 --platform=ruby -- --with-mysql-dir=c:/your path to Ruby31-x64/msys64/mingw64
(no particular quote was neeeded and I used forward slashes).
It is an open issue with mysql2 though there is a workaround. Check this thread from GitHub the last comment is the thing you need.

AWS Codebuild error while installing SASSC gem wrong ruby version

I'm running a Codestar project. Sample app installs fine. When I add my application in with SASSC get failure, because of Ruby version. Is there away to notify CodeBuild to upgrade Ruby version? tried looking through buildspec.yml am I anywhere close? trying to google.
In middle of build logs
Installing sassc 2.0.0 with native extensions
Gem::InstallError: sassc requires Ruby version >= 2.3.3.
At end of build logs
An error occurred while installing sassc (2.0.0), and Bundler cannot continue.
Make sure that `gem install sassc -v '2.0.0'` succeeds before bundling.
[Container] 2018/12/31 04:17:42 Command did not exit successfully bundle install exit status 5
[Container] 2018/12/31 04:17:42 Phase complete: INSTALL Success: false
[Container] 2018/12/31 04:17:42 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: bundle install. Reason: exit status 5
thanks.
I changed Codebuild environment from AWS Linux distro to Ubuntu with Ruby 2.5.3 which fixed my problem. Unless someone has a better answer.

Rails installation on hostmonster bundle install fails

So I had a rails app up and working on my hostmonster account just fine. I then updated a few things in my dev environment / pushed them up to github / pulled them back down on my production environment. Now its giving me the error Could not find pg-0.17.1 in any of the sources (Bundler::GemNotFound).
This is a new gem i installed in my dev because i was attempting to move to postgresql for dev and live....for now im using postgresql in dev and mysql2 in production. I know this isn't optimal but im working on it.
I tried running bundle install to get the pg gem installed and it fails with the error
Gem::Exception: Cannot load gem at [/usr/lib64/ruby/gems/1.9.3/cache/rake-10.2.2.gem] in /home4/muscorei/workspace/vollapp
An error occurred while installing rake (10.2.2), and Bundler cannot continue.
Make sure that gem install rake -v '10.2.2' succeeds before bundling.
I try installing rake and it works fine...try again..same error. I have found one question on here that seems to fix this for others but it requires running of gem update --system which you cannot do for hostmonster. Any ideas?
So here is another "related" issue. When i type in gem list --local I see that rails is installed at version 4.1.0....however when i do rails -v it shows the systemwide version of 3.2.13. I don't EVER have any of these annoying issues on my dev environment.

Bundler error when trying to deploy with Capistrano

I am trying to deploy to a remote VPS via Capistrano 3. The VPS tuns on Ubuntu 12.04, Apache, and rvm. When I use cap production deploy on my local computer, it begins to deploy, but then throws a bundler error and quits:
An error occurred while installing minitest (4.7.5), and Bundler cannot continue.
See here for documentation: https://gist.github.com/atkolkma/9551199
gem install minitest -v 4.7.5
Executes successfully. But if I run
gem -v minitest
It says I have version 2.2.2 ! This happens on BOTH machines. Could it be rvm that is doing this? A bundler issue? I have no idea.
UPDATE: I installed RVM, Ruby and Rails as root on the VPS. I am pretty sure this was causing permissions or path problems for Capistrano when trying to bundle my project. I will try to rebuild the VPS with a deployer or rails user. I'll update when I solve this problem.
UPDATE: I installed RVM, Ruby and Rails as root on the VPS. I am pretty sure this was causing permissions or path problems for Capistrano when trying to bundle my project. I will try to rebuild the VPS with a deployer or rails user. I'll update when I solve this problem.

Resources