When I try to deploy my app to Bluemix I get the following error. My manifest.yml file is here as follows.
applications:
- path: .
memory: 512M
instances: 1
domain: mybluemix.net
name: KnowYourBrand
host: kyb
command: bundle exec rake db:setup && bundle exec rails s -p $PORT
disk_quota: 1024M
services:
- Personality Insights-n2
- Tone Analyzer-uu
- Insights for Twitter-bt
- kybSQLDB
- AlchemyAPI-tw
buildpack: https://github.com/ibmdb/db2rubybuildpack
2015-11-17T13:04:51.55-0600 [App/0] ERR LoadError: libdb2.so.1:
cannot open shared object file: No such file or directory -
/home/vcap/app/vendor/bundle/ru by/2.2.0/extensions/x86_64-linux/
2.2.0-static/ibm_db-2.6.1/ibm_db.so
My gemfile is as follows:
source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
gem 'backbone-on-rails'
gem 'whenever', :require => false
group :production do
gem 'ibm_db'
gem 'rails_12factor'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-script-source', '1.8.0'
gem 'coffee-rails', '~> 4.0.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-ruby', '>= 3.1.2', :platform => :ruby
gem 'httparty'
gem 'figaro'
gem "cf-autoconfig", "~> 0.2.1"
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development do
gem 'byebug'
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
gem 'pry-rails'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
end
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
What could the issue be? I tried setting the ibm_db version to an older version, but that did not resolve the issue either.
Environment variable IBM_DB_HOME is not set. Set it to your
DB2/IBM_Data_Server_ Driver installation directory and retry gem
install.
What is the best way to handle this without having to install a driver on my local machine? I am just trying to deploy it to Bluemix.
I'm not entirely sure, but it appears that you need to set the IBM_DB_HOME environment variable. You can configure environment variables either using the cf set-env command, in your manifest.yml file, or in the Bluemix dashboard. I'm not familiar enough with ibm_db gem or DB2 to say what the value should be for this environment variable, but this README in the gem may be helpful (search the page for "IBM_DB_HOME").
You can track this question in ibm_db git issue repository here
The ibm_db gem auto downloads the required files while installing the gem. However after ibm_db gem is installed in Bluemix, it is not able to link the downloaded libraries.
To resolve this problem, please follow below steps.
Step-1. While pushing application with migration, pass a command to set LD_LIBRARY_PATH environment variable as below.
cf push BlogApp2 -c "export
LD_LIBRARY_PATH=/home/vcap/app/vendor/bundle/ruby/2.2.0/gems/ibm_db-3.0.0/lib/clidriver/lib:$LD_LIBRARY_PATH;
bundle exec rake db:migrate"
Note : While running above commad, please specify the Ruby version and ibm_db version that you have specified in gemfile. You can also refer the path in LoadError: libdb2.so error message that you see in server logs on Bluemix.
After application is pushed, you will see that migration has run and you will also see database connection error which is expected.
Step-2. Add below Environment Variable in your application. Login to bluemix -> select your Ruby application -> Click on Environment Variables manu -> Select User defined. -> Add below variable -> Save.
Name - LD_LIBRARY_PATH
Value - /home/vcap/app/vendor/bundle/ruby/2.2.0/gems/ibm_db-3.0.0/lib/clidriver/lib:$LD_LIBRARY_PATH [Refer step-1 for the value]
After adding LD_LIBRARY_PATH to your application in Bluemix, you can push your application from cf command as below.
cf push BlogApp2 -c "null"
Now your application will connect to SQLDB.
Thanks,
Arvind
I ran across this post when I was setting up a Docker image for a node.js server that uses ibm_db. I know this is a ruby app, but this information may help the next person down the road. Here is my Dockerfile that makes node_db available and working.
FROM node:10
# Create app directory
WORKDIR .
# need to download the ibm drivers and set IBM_DB_HOME
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
RUN mkdir /ibmdriver
RUN curl https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz \
| tar -xzf - -C /ibmdriver/
ENV IBM_DB_HOME /ibmdriver/clidriver
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$IBM_DB_HOME/lib
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available ([email protected]+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm install --only=production
# Bundle app source
COPY . .
ENV BCCB_DECISIONTREE_SERVICE_PORT 3000
EXPOSE 3000
CMD [ "npm", "start" ]
Related
I installed that gem,when I run
rails g active_scaffold:install
It says
Running via Spring preloader in process 6001
Could not find generator 'scoffold'. Maybe you meant 'scaffold', 'css:scaffold' or 'erb:scaffold'
Run rails generate --help for more options.
gemfile
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
gem 'active_scaffold', github: 'activescaffold/active_scaffold', branch: 'master'
I found the solution
I changed the steps to install the gem, that steps are
1.Insert the gem in gem file, gem 'active_scaffold' and run bundle install.
2.Run the command "rails g active_scaffold User name:string".
3.In gemfile change gem 'active_scaffold' to "gem 'active_scaffold', github: 'activescaffold/active_scaffold', branch: 'master' " and install the bundle once again.
4.Create a DB by "bundle exec rake db:create".
5.Run "rails g active_scaffold:install".
6.Finally migrate it "rake db:migrate"
I have a Rails app on OpenShift Online that I'm trying to setup with RAILS_ENV=development as opposed to the default env of production. The idea being later on I'll add test, staging and production domains.
My problem is that because the env is set to development the OpenShift process that runs when I do a git push says it's skipping "bundle install":
remote: NOTE: Skipping 'bundle install' because running in development mode.
I got it to do the bundle install by setting RAILS_ENV to production temporarily.
Is there a way to force a bundle install in the OpenShift Online environment when running in development mode?
UPDATE:
Tried forcing a bundle install via .openshift/action_hooks/pre_build. Getting Gemfile syntax error during pre_build hook. Gemfile works locally and on OpenShift when using RAILS_ENV = production.
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.4'
### OpenShift Online changes:
# Fix the conflict with the system 'rake':
gem 'rake', '~> 0.9.6'
# Iron.io gems
gem 'iron_mq'
#gem 'iron_worker_ng'
# Support for databases and environment.
# Use 'sqlite3' for testing and development and mysql and postgresql
# for production.
#
# To speed up the 'git push' process you can exclude gems from bundle install:
# For example, if you use rails + mysql, you can:
#
# $ rhc env set BUNDLE_WITHOUT="development test postgresql"
#
group :test do
gem 'sqlite3'
gem 'minitest'
end
group :development, :test do
gem 'thor'
end
# Add support for the MySQL
group :development, :production, :mysql do
gem 'mysql2'
end
### / OpenShift changes
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.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
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# 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
# Use debugger
# gem 'debugger', group: [:development, :test]
.openshift/action_hooks/pre_build
#!/bin/bash
# This is a simple script and will be executed on your CI system if
# available. Otherwise it will execute while your application is stopped
# before the build step. This script gets executed directly, so it
# could be python, php, ruby, etc.
if [[ "$RUBY_VERSION" == "1.8" ]]; then
echo "ERROR: This quickstart is not compatible with Ruby 1.8"
echo "ERROR: Please use ruby-1.9 or ruby-2.0 application type."
exit 1
fi
if [[ "$RAILS_ENV" == "development" ]]
then
echo "Forcing bundle install for environment: $RAILS_ENV"
pushd $OPENSHIFT_HOMEDIR/app-root/repo > /dev/null
bundle install --path ./vendor/bundle
popd > /dev/null
fi
Output from "git push" to OpenShift Online app
remote: Stopping MySQL 5.5 cartridge
remote: Ruby cartridge in development mode, skipping stop...
remote: Force clean build enabled - cleaning dependencies
remote: Building git ref 'master', commit 5c3182d
remote: Forcing bundle install for environment: development
remote: Gemfile syntax error:
remote: /var/lib/openshift/540306395973ca6dc30006bc/app-root/runtime/repo/Gemfile:56:
remote: syntax error, unexpected ':', expecting $end
remote: gem 'sdoc', '~> 0.4.0', group: :doc
remote: ^
remote: Building Ruby cartridge
remote: NOTE: Skipping 'bundle install' because running in development mode.
remote: Preparing build for deployment
remote: Deployment id is a65ea3ad
remote: Activating deployment
remote: Starting MySQL 5.5 cartridge
remote: NOTE: The 'rake assets:precompile' is disabled when Ruby is in development mode.
remote: bundle exec rake db:migrate RAILS_ENV=development
remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find rake-0.9.6 in any of the sources (Bundler::GemNotFound)
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
remote: from /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
remote: from /opt/rh/ruby200/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:53:in `require'
remote: from /opt/rh/ruby200/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:53:in `require'
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 540306395973ca6dc30006bc (Error activating gear: CLIENT_ERROR: Failed to execute action hook 'deploy' for 540306395973ca6dc30006bc application pvcentral)
remote: Deployment completed with status: failure
remote: postreceive failed
To ssh://540306395973ca6dc30006bc#pvcentral-pervasivdev.rhcloud.com/~/git/pvcentral.git/
8d74e27..5c3182d master -> master
I was able to force a bundle install with RAILS_ENV=development by doing two things:
Modified the pre_build action hook to execute "bundle install" with the correct version of ruby and environment context
Added the force_clean_build marker
NOTE: My app was created using the Rails 4 (4.1.4) and Ruby 2.0 quickstart.
What I tried above after the suggestion to add "bundle install" to an action hook (turns out pre_build is the correct one to modify) was okay except executing as:
bundle install --path ./vendor/bundle
results in a weird Gemfile syntax error on 'sdoc'.
I noticed that the deploy action hook included code to source a couple of files to set the ruby version and execution context. And also executed "bundle" as:
ruby_with_nodejs_context "bundle exec rake db:migrate"
After adding the "right" execution context (see below), the Gemfile syntax error disappeared. Finally, I had to add the force_clean_build marker because without it I was getting errors:
remote: Building Ruby cartridge
remote: Restoring previously bundled RubyGems
remote: NOTE: You can commit .openshift/markers/force_clean_build to force a clean bundle
remote: ERROR: You need to remove the ".bundle" directory from your GIT repository.
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/54077e9a5973ca2e6900096f/ruby
.openshift/action_hooks/pre_build
source $OPENSHIFT_CARTRIDGE_SDK_BASH
source ${OPENSHIFT_RUBY_DIR}/lib/ruby_context
pushd ${OPENSHIFT_REPO_DIR} >/dev/null
if [[ -f .openshift/markers/force_clean_build && "$RAILS_ENV" == "development" ]]
then
echo "bundle install --path ./vendor/bundle"
ruby_with_nodejs_context "bundle install --path ./vendor/bundle"
fi
popd > /dev/null
You could setup an action hook to run bundle install. Try this article: https://www.openshift.com/developers/deploying-and-building-applications look at the Customizing OpenShift's Build Process section.
Everytime I try and push my project to Heroku by using git push heroku master I get the following response. I have a macbook air OSX-10.8.
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
New app detected loading default bundler cache
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Fetching git://github.com/thomas-mcdonald/bootstrap-sass.git
fatal: Could not parse object '9c6c07f74ff515cf38380b014cfede14a4f0eae4'.
Git error: command `git reset --hard 9c6c07f74ff515cf38380b014cfede14a4f0eae4`
in directory
/tmp/build_260d9aa7-1d8e-4738-b10f- fce9113dd86e/vendor/bundle/ruby/2.0.0/bundler/gems/bootstrap-sass-9c6c07f74ff5
has failed.
If this error persists you could try removing the cache directory
'/tmp/build_260d9aa7-1d8e-4738-b10f-fce9113dd86e/vendor/bundle/ruby/2.0.0/cache/bundler/git/bootstrap-sass-33efd1d8ffb6176fdb805029a30f02a6edfbae2e'
Bundler Output: Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Fetching git://github.com/thomas-mcdonald/bootstrap-sass.git
fatal: Could not parse object '9c6c07f74ff515cf38380b014cfede14a4f0eae4'.
Git error: command `git reset --hard 9c6c07f74ff515cf38380b014cfede14a4f0eae4`
in directory
/tmp/build_260d9aa7-1d8e-4738-b10f-fce9113dd86e/vendor/bundle/ruby/2.0.0/bundler/gems/bootstrap-sass-9c6c07f74ff5
has failed.
If this error persists you could try removing the cache directory
'/tmp/build_260d9aa7-1d8e-4738-b10f-fce9113dd86e/vendor/bundle/ruby/2.0.0/cache/bundler/git/bootstrap-sass-33efd1d8ffb6176fdb805029a30f02a6edfbae2e'
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app
To git#heroku.com:fierce-taiga-8706.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:fierce-taiga-8706.git'
Here is are my git remotes
heroku git#heroku.com:sheltered-crag-6550.git (fetch)
heroku git#heroku.com:sheltered-crag-6550.git (push)
origin git#github.com:TheM00se/Pinteresting.git (fetch)
origin git#github.com:TheM00se/Pinteresting.git (push
Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '4.0.1'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3'
group :doc do
gem 'sdoc', require: false
end
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
I've been trying to figure out a solution for 2 hours and really I'm not even sure what the problem is .
The problem is with:
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3'
If you check the link below:
https://github.com/thomas-mcdonald/bootstrap-sass/branches
The branch seems to be deleted, maybe it was merged into the master branch, based on feedback from the OP, anyone using it subsequently should add the below to their Gemfile:
gem 'sass-rails', '>= 3.2' # sass-rails needs to be higher than 3.2
gem 'bootstrap-sass', '~> 3.0.3.0'
I want to use activeadmin for my rails project, so I added it to my gemfile.
gem 'activeadmin'
and updated the bundle, but received this error message -
Resolving dependencies...
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
activeadmin (>= 0) ruby depends on
actionpack (~> 3.0.0.rc2) ruby
rails (= 4.0.0) ruby depends on
actionpack (4.0.0)
I uploaded the project in github; this is the link of the gemfile - https://github.com/Mashpy/esl/blob/master/Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.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', '~> 1.2'
#gem
gem 'activeadmin'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
What am I doing wrong that is preventing me from adding activeadmin?
Active Admin has a few other dependencies as well. Check this out Active Admin install with Rails 4.
Copy and paste all the gems (in the top answer) to your gemfile and you should not have any issues running bundle.
You can update your bundle using -
bundle update
Then
bundle install
To make sure your configuration of the gems are right.
I think you should upgrade these gems :
sass-rails ~> 3.2.3
coffee-rails ~> 3.2.1
References:
http://guides.rubyonrails.org/3_2_release_notes.html
I'm having a problem with getting delayed_job to start in the production environment. Everything works as it should in development just using the rake jobs:work command, but after deploying to my server with Capistrano, and hours of failed attempts later, I cannot figure out how to get DJ running.
As it says to do on the github repository for delayed_job, I made sure I bundled the "daemons" gem, and also attempted to start it with the command "bin/delayed_job start" instead of "script/delayed_job start" since I'm on rails 4. I've also ran the required generator "rails generate delayed_job" which did generate this file inside the bin directory of my project:
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
The error I'm consistently getting is -bash: bin/delayed_job: No such file or directory which I think could be since I'm using rvm.
As for my gemfile, I've included delayed_job_active_record and daemons. At this point I'm completely stumped and out of links to explore.
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
# Rails defaults
gem 'sass-rails', '~> 4.0.0'
gem 'bundler'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
# learn-rails
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails', :github => 'anjlab/bootstrap-rails'
gem 'figaro'
gem 'gibbon'
gem 'high_voltage'
gem 'simple_form', '>= 3.0.0.rc'
gem 'delayed_job_active_record', '~> 4.0.0'
group :development, :test do
gem 'sqlite3'
gem 'better_errors'
gem 'quiet_assets'
gem 'capistrano', '~> 2.15.5'
gem 'rvm-capistrano'
gem 'rspec-rails'
end
group :test do
gem "factory_girl_rails", "~> 4.0"
gem 'capybara'
gem 'poltergeist'
gem "faker", "~> 1.2.0"
end
group :production do
gem 'unicorn'
gem 'pg'
gem 'daemons'
end
Make sure the first line in bin/delayed_job points to a valid Ruby executable. You're using just ruby which probably can't be resolved. rvm is adding the full path to ruby when you cd into the rails_root directory, but that's not happening when the script is executed. One slightly hacky solution would be to cd into the directory, do a which ruby and write that into bin/delayed_job, such as: #!<path_to_ruby>. No need to call /usr/bin/env since Capistrano is doing this already.