Error deploying with cap deploy when using gem paperclip - ruby-on-rails-3

I am using the gem Paperclip and now I wanted to deploy my app to the server using capistrano, but when run cap deploy I get the following message at the end:
* executing "cd /home/administrator/myApp/releases/20120506165329 && bundle install --gemfile /home/administrat
or/myApp/releases/20120506165329/Gemfile --path /home/administrator/myApp/shared/bundle --deployment --qui
et --without development test"
servers: ["myserver.com"]
[myserver.com] executing command
** [out :: myserver.com] Gem::InstallError: paperclip requires Ruby version >= 1.9.2.
** [out :: myserver.com] An error occured while installing paperclip (3.0.3), and Bundler cannot continue.
** [out :: myserver.com] Make sure that `gem install paperclip -v '3.0.3'` succeeds before bundling.
command finished in 66362ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/administrator/myApp/releases/20120506165329; true"
servers: ["myserver.com"]
[myserver.com] executing command
command finished in 66ms
failed: "sh -c 'cd /home/administrator/myApp/releases/20120506165329 && bundle install --gemfile /home/administra
tor/myApp/releases/20120506165329/Gemfile --path /home/administrator/myApp/shared/bundle --deployment --qu
iet --without development test'" on myserver.com
I have checked the version of Ruby in my server and I got:
$ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
I have also intalled the gem manually in the server by running
gem install paperclip -v '3.0.3'
...
Successfully installed paperclip-3.0.3
and ran cap deploy again, but the same message showed up
how can I deploy my app?
thanks you in advance

It was fixed by setting de default environments of capistrano as suggested in the accepted answer here
I can now deploy with capistrano (although my system ruby is still using ruby 1.8.7 so the gem paperclip does not get installed properly, you can find this problem here)

Related

mysql2 Gem::Ext::BuildError: ERROR: Failed to build gem native extension

When I download the rails application from github
https://github.com/ari/jobsworth
An then give bundle install it throws error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.4'` succeeds before bundling.
After I give the sudo gem install mysql2 -v '0.4.4' and it displays like:
Fetching: mysql2-0.4.4.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.4.0/gems/mysql2-0.4.4/ext/mysql2
/usr/bin/ruby2.4 -r ./siteconf20180212-10708-v1q8lj.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.4.0/gems/mysql2-0.4.4 for inspection.
Results logged to /var/lib/gems/2.4.0/extensions/x86_64-linux/2.4.0/mysql2-0.4.4/gem_make.out
After run bundle install it throws same error.
Running these commands worked for me.
brew install openssl
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
bundle
You can refer to this link for further help https://github.com/brianmario/mysql2/issues/1005

cap deploy:migrations fails with Could not locate Gemfile

I'm working on my first rails deployment and having a problem I can't figure out.
mac osx 10.8.2
ruby 1.8.7
Rails 3.2.6
rvm 1.17.2
I've been following this tutorial http://brandnewrails.wordpress.com/ and got stuck on 7c.
I set it all up in RVM, got git running on the server, ran bundle install in the app, and wrote the Capistrano recipe in my_app/config/deploy.rb
Then I ran:
$ capify . no problem
$ cap deploy:setup no errors
$ cap deploy:check returned You appear to have all necessary dependencies installed
$ cap deploy:migrations is where the problem happens. After successfully running a bunch of the commands, capistrano fails. See below:
2012-12-10 00:43:56 executing `bundle_install'
* executing "cd /home/{servername}/party/releases/20121209134354 && bundle install --path vendor/bundle"
servers: ["{servername}"]
[{servername}] executing command
** [out :: {servername}] Could not locate Gemfile
command finished in 694ms
failed: "sh -c 'cd /home/alexchee/party/releases/20121209134354 && bundle install --path vendor/bundle'" on {servername}
Does anyone know what to do? When I check the app directory, the Gemfile is there. Any ideas or further questions?
The inability of capistrano to locate a Gemfile in this case seems to be a symptom of not having initiated git in the app locally, that is on my own computer.
My hunch is that since Gemfile is the first file in the list above, that is why it created an error first. If the program had continued, it would have probably had other errors as well.
Even if git is running on the server and the app is bundled up correctly, you must also initiate git locally and direct it to the appropriate files on your server in order for the deploy to work.
Great instructions are listed here: http://brandnewrails.wordpress.com/2012/10/14/lesson-7b/

Could not find gem 'mocha (= 0.12.3) x86-mingw32'

I try to launch redmine from IDE:
rails/redmine/script/rails server -b 127.0.0.1 -p 3000 -e development
but I am getting error:
/resolver.rb:287:in `resolve': Could not find gem 'mocha (= 0.12.3) x86-mingw32' in the gems available on this machine. (Bundler::GemNotFound)
I installed mocha:
gem install mocha
But error still appear.
Try installing it with the same exact version:
gem install mocha -v '0.12.3'

Getting gem exception while deployin code on server

Hi i am getting a gem exception error:
Gem::Exception: Cannot load gem at [/usr/lib/ruby/gems/1.8/cache/Ascii85-1.0.1.gem] in /home/profweb/rails-apps/profitnext/releases/20120628123949
** [out :: profitnext.com] An error occured while installing Ascii85 (1.0.1), and Bundler cannot continue.
** [out :: profitnext.com] Make sure that `gem install Ascii85 -v '1.0.1'` succeeds before bundling.
command finished in 607967ms
*** [deploy:update_code] rolling back
Although i have installed that gem in gem file and it shows in gem list on local host. Can somebody tell me why i am getting this error in "cap deploy" command.
Are you sure you have all dependencies installed on the remote host? Similar errors are produced if you're installing a gem and don't have required packages installed on your system
i got where the real problem is. I have added a line in my "deploy.rb" file and added the required gem in my gemfile and run the bundle install. Now i can easily deploy my code. Thanks for reply friends.

Capistrano & jruby & rvm - Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources

I encountered Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources during deploying my application using capistrano, and when processing deploy:assets:precompile.
The command is:
cd /opt/app/deploy/entercamp/releases/20120627132117 && /usr/local/rvm/rubies/jruby-1.6.7/bin/jruby --1.9 -S bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile
I tried the command manually on the server and it works quite ok. And I could see that rake-0.9.2.2 is installed in the result output of bundle:install in the deploy process.
Where could be the problem?
Detailed information is in: https://gist.github.com/3005237
This just got fixed with help of Michal from rvm-capistrano project.
It raises this error is because jruby is install with version 1.8 by default and it tries to switch to 1.9 when deploying and that causes the problem.
The solution is to install jruby with version 1.9 by default: rvm install jruby-1.6.7.2 --1.9 and then it works.