How to avoid Error in deploy with Ruby on Rails - ruby-on-rails

Whenever I try to deploy my system the following error occurs:
root#:/var/www/code# bundle exec rake assets:precompile db:migrate RAILS_ENV=production
rake aborted!
LoadError: incompatible library version - /var/www/code/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/nokogiri.so
/var/www/code/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri.rb:32:in `require'
I tried to make an update on all gems:
gem update
And I followed the "Incompatible library version on Ubuntu 16.04" issue, but yet it doesn't work.
Why does this happen?
I circled the uninstallation and installation code at the root of the project:
root#:/var/www/code# gem uninstall nokogiri
And then:
root#:/var/www/code# gem install nokogiri
My gem list shows:
root#:/var/www/code# gem list
- nokogiri (1.7.1)
But when I try to compile it appears again:
/code/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/nokogiri.so
Should I accomplish this within the gems/ folder?

Related

Bundler::GemRequireError: There was an error while trying to load the gem 'manticore'

I am trying to run a jruby rails app locally and bundler throws me the following error
Bundler::GemRequireError: There was an error while trying to load the
gem 'manticore'.
My $bundle install was successful and $gem list confirmed that the gem exists in my local environment.
manticore (0.5.2 java)
Not sure why it is failing to load the gem!?
Ruby - "jruby-1.7.16.1"
Java - "1.8.0_40"
Reinstall the gem and see if it loads.
Remove manticore gem from your Gemfile.
Do a "gem uninstall manticore"
Add manticore to gemfile again and perform a "bundle install"
run jruby with bundle exec

Problems with migration from older ruby/rbenv

I faced with the following problem:
I update my OS X to Yosemite, switched to ruby 2.2.2 and decided to come back to my Octopress-based blog. Below I try to describe all my actions one by one, will be glad if someone tell me where I did something wrong.
So I cloned my page from github , checkout to source branch. But when I try to execute any rake command I get error:
rbenv: version `1.9.3-p194' is not installed
rbenv: version `1.9.3-p194' is not installed
I did:
> rbenv local --unset
> rake reharsh --trace
rake aborted!
LoadError: cannot load such file -- bundler/setup
MYPATH/Rakefile:2:in `<top (required)>'
Thus I install bundler:
> gem install bundler
> bundle install
Fetching gem metadata from http://rubygems.org/...........
Fetching version metadata from http://rubygems.org/...
Fetching dependency metadata from http://rubygems.org/..
Installing rake 0.9.2.2
etc
Finally:
> rake generate --trace
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 0.9.2.2. Prepending `bundle exec` to your command may solve this.
UPD: Following advices of K M Rakibul Islam, I changed in the gemfile rake version from 0.9.2 to 10.4 and added line gem 'iconv' to the gem file. After that rake generate start working.
As the error message suggests, you should run the rake command using bundle exec in order to run it in the context of your Gemfile:
bundle exec rake generate --trace
This should fix your issue.
Update
change this: gem 'rake', '~> 0.9.2' to gem 'rake', '~> 10.4.2' in your Gemfile and run: bundle install.

Ruby on rails error when running rails s

Um quite new to rails and um getting an error when run the command
rails s
it says
Could not find rake-0.9.2.2 in any of the sources
Run bundle install to install missing gems.
when I run bundle install nothing happened
my gem list has rake 0.9.2.2
what can go wrong?
my ruby version is 1.9.3
Thank you in advance
Remove all the versions of Rake ==> gem uninstall rake
Remove your gemfile.lock => rm Gemfile.lock
Remove gem 'rake' on your gemfile
Run bundle install
Install Rake manually : gem install rake --version=10.0.4
When you use command gem list, you will get a list of gem installed on your machine.
For example : rake (10.0.4, 10.0.3, 0.9.2.2)
Just see the console which gem is compatible with your application. It is already mentioned in the error log message.
Use
gem uninstall rake
Keep the suitable one and remove the version who is creating trouble. And then run rails s or bundle exec rails s
Try using rvm and go back to ruby 1.8.7 instead of 1.9.2. This fixed it for me. Don't forget to install rails again (sudo gem install rails while already on 1.8.7) if you have only installed rails for 1.9.3.]

Ruby on Rails : Rake db:create -> Could not find gem

I begin with ruby on rails and I'm trying to create my first blog. So i ran:
rails new blog -database=mysql
There was an error:
Gem::InstallError: The 'json' native gem requires installed build tools.
But since i saw a json directory in my blog's directory i didn't care.
So i run the command to create the database:
rake db:create --trace
And i had another error:
Could not find gem 'rails (= 3.1.3) x86-mingw32' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
Does anybody knows what is the problem?
Also may need to run
bundle exec rake db:create
you can try "gem list | grep json" to check if json is already install.
Then, you can add following line in Gemfile (in your site's directory):
gem 'json'
and then
bundle install json or bundle update json
Good luck,

Rails ruby script/server error -- no such file to load -- gdata/spreadsheet

Rails ruby script/server error -- no such file to load -- gdata/spreadsheet
I have require gdata/speadsheet in /Users/me/myapp/vendor/gems/roo-1.2.3/lib/roo/google.rb
I cannot figure out how to install it.
Tried
gem install gdata_spreadsheet
gem install spreadsheet
gem install gdata
Which all seem to install, but still get
no such file to load -- gdata/spreadsheet
When
ruby script/server.
Any ideas on how to get this file?
Assuming you are using bundler for dependencies try adding the gem to your Gemfile:
gem 'gdata_spreadsheet'
Then use bundler to install your dependencies and start your server:
bundle
bundle exec script/server

Resources