Ask A Question

Notifications

You’re not receiving notifications from this thread.

Deploy Ubuntu 14.04 Trusty Tahr Discussion

Chris Oliver asked in General

I'm trying to install Ruby 2.2 on my staging server through rbenv and it's just hanging:



deployer@http01-staging:~$ rbenv install 2.2.0
Downloading ruby-2.2.0.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc
Installing ruby-2.2.0...

Any ideas??

* UPDATE*
It finally failed and I got the following error messages:


BUILD FAILED (Ubuntu 14.04 using ruby-build 20150116-6-g7f1d8df)

Inspect or clean up the working tree at /tmp/ruby-build.20150122190357.31648
Results logged to /tmp/ruby-build.20150122190357.31648.log

Last 10 log lines:
make[3]: Leaving directory /tmp/ruby-build.20150122190357.31648/ruby-2.2.0/ext/fiddle/libffi-3.2.1'<br>linking shared-object fiddle.so<br>/usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC
./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
make[2]: Leaving directory /tmp/ruby-build.20150122190357.31648/ruby-2.2.0/ext/fiddle'<br>make[1]: *** [ext/fiddle/all] Error 2<br>make[1]: Leaving directory/tmp/ruby-build.20150122190357.31648/ruby-2.2.0'
make: *** [build-ext] Error 2

Reply

I ran into this issue trying to install ruby 2.2 from source. More info here: https://github.com/sstephen...
You can set CFLAG=-fPIC

or install sudo apt-get install libffi-dev

Reply

I'm having trouble at the step of installing Ruby with rbenv. rbenv installed fine but when I run rbenv install 2.2.0 it hangs (not really hangs, I can see stuff happening if I use the --verbose flag), and then I get the following:



deployer@http01-staging:~$ rbenv install 2.2.0

Downloading ruby-2.2.0.tar.gz...

-> http://dqw8nmjcqpjn7.cloudfront.net/7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc

Installing ruby-2.2.0...

BUILD FAILED (Ubuntu 14.04 using ruby-build 20150116-6-g7f1d8df)

Inspect or clean up the working tree at /tmp/ruby-build.20150122204243.31132

Results logged to /tmp/ruby-build.20150122204243.31132.log

Last 10 log lines:

make[3]: Leaving directory `/tmp/ruby-build.20150122204243.31132/ruby-2.2.0/ext/fiddle/libffi-3.2.1'

linking shared-object fiddle.so

/usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value

collect2: error: ld returned 1 exit status

make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1

make[2]: Leaving directory `/tmp/ruby-build.20150122204243.31132/ruby-2.2.0/ext/fiddle'

make[1]: *** [ext/fiddle/all] Error 2

make[1]: Leaving directory `/tmp/ruby-build.20150122204243.31132/ruby-2.2.0'

make: *** [build-ext] Error 2

Any suggestions??

Reply

Used only a portion of this tutorial; using rbenv to install ruby version 2.1.3; i was having problems installing mechanize gem. The part where you showed how to setup ruby using rbenv benefited me. Excellent tutorial

Reply

So how do you got about debugging errors where Capistrano cannot find gems. Even when gems are in the Gemfile and work just find if you run the rails app with 'rails s'

Reply

I went through the tutorial. I had a few issues but managed to get through it.
However now that I have finished it. It looks like the rails application is not actually running.
There are no log files in 'myapp'/log (I am not sure where they logs would be).
When I go to the IP address for my server all I see is the welcome to nginx. I am not sure if there is supposed to be another url I go to instead.

Reply

Make sure to restart nginx after changing the configs. You can double check /var/log/nginx/error.log for Nginx errors if you get any issues.

Reply
Sean Perryman Sean Perryman

Hey Chris, great tutorial! I am stuck at the end here, I've been beating my head against the wall all afternoon trying to get it to work. I am getting this error in my production.log:

ActiveRecord::NoDatabaseError (FATAL: role "deploy" does not exist);

Here is my database.yml:

production:
adapter: postgresql
encoding: unicode
pool: 5
host: ""
database: itt_production
username: postgres
password: ""

My pg_hba.conf has everything in trust mode, so this should work. When I switch the pg_hba.conf over to password or md5, and put a password in the database.yml file, I get an error that no password was provided; even though I've provided one. I noticed someone else had an error like this down in the comments, but there was not a resolution posted. Is this something you are familiar with?

Reply
Sean Perryman Sean Perryman

HAHA! After switching everything to blank password string and trust, and rebooting the server, the site just loaded up for me. I'd restarted the rails instance, as well as postgres service, but I guess that wasn't enough. This leads to the next question of getting this to work with a password or some other more secure method; luckily this deployment is only for an intranet site.

Reply

sudo nginx -t

nginx: [emerg] invalid number of arguments in "passenger_ruby" directive in /etc/nginx/nginx.conf:72

nginx: configuration file /etc/nginx/nginx.conf test failed

Result of "which ruby"
passenger_ruby /home/deploy/.rvm/rubies/ruby-2.2.0/bin/ruby

Reply

There's a typo in the tutorial there. You actually want the .wrapper version commented out in the example config there. I'll get that fixed shortly!

Reply

hello, i did everything like in this tutorial, but when i try to access my vserver i just get a "Incomplete response received from application" response in my browser.

Reply

This is caused by the lack of a secret_key_base export. http://stackoverflow.com/qu...

Reply

Users using the RVM method need to execute this command after 'source ~/.rvm/scripts/rvm' -- 'echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc'; otherwise if you exit the terminal session and log back in it will not be loaded. If you are getting a message that 'rails' isn't an installed gem this is likely the cause I would think.

Reply
Ben Polinsky Ben Polinsky

Thanks, should be more visible

Reply

I don't get this and it's getting infuriating. I go to my site folder, cd to current, run "rails c" and I get:

WARNING:root:could not open file '/etc/apt/sources.list.d/passenger.list'

The program 'rails' can be found in the following packages:

* ruby-railties-3.2
* ruby-railties-4.0

Try: sudo apt-get install <selected package="">

So I put source ~/.rvm/scripts/rvm and run rails c again. Same result. I cannot get the effing console to start and I'm about to lose my cool. I'm going on 2 hours wasted on this and it's absolutely infuriating.

Reply

Can the guide be updated with how to correctly handle the production database.yml and adding the secret_key as an environment variable for for nginx?
It is also a bit unclear about at what point are we cloning the repo to the machine vs what is committed to the repo.

Reply

Definitely. That's one of my major goals to add to this tutorial. It's an important piece and I kind of glossed over it. I also need to do a screencast to explain how it works as well.

Reply

`cap production deploy` returns `ERROR rbenv: 2.0.0-p451 is not installed or not found in ~/.rbenv/versions/2.0.0-p451`. Any ideas?

Reply

found it. The Capfile has to declare version 2.2.0 instead. I also ended up renaming the folder in `versions`

Reply
Steven Magelowitz Steven Magelowitz

Excellent tutorial! Any chance you can explain how to set up multiple rails apps on a single droplet?

Reply

The only difference is to deploy your other apps to separate folders, create their dbs, and add another server config to nginx so it knows to serve it up on a different domain/subdomain.

Reply
Ivor Horton Ivor Horton

"The first step is to add Capistrano to your Gemfile"

Here we create a new Rails project and edit it's Gemfile or just create a file called Gemfile anywhere in the system?

Reply

Always the file named Gemfile in the root of your Rails application. It's the defining list of dependencies for each Rails app. You save it in each app so that all of them can use different versions without fighting each other.

Reply
Ivor Horton Ivor Horton

What should changed if my project is private and I don't want to put on github?

Reply

Most of my projects are private and I put them on Github (paying for private repos) and you could easily store them privately on Bitbucket. In either case, your Capistrano URL will securely authenticate with Github or Bitbucket using your SSH key to check out the code. It logs in using that so you don't need to use a password to clone the code on a deploy.

Reply

Hi! I followed all the tutorial and everything is working fine. The only thing I cannot do and I would like to be able to do is to run rails console on the server. When I run 'RAILS_ENV=production bundle exec rails console' in the /current folder it looks like there isn'n a rails project. I'm missing something in the command? How can i get the console working? Thank you

Reply

That's exactly the command and the location you need to in order to do it.

Are you sure you're in the right directory? When you run ls it shows all the files in your rails app?

Reply
Alejandro Ventura Alejandro Ventura

is there a video about it?
Thanks!

Reply

Thank you for step by step process. I ended up with 403 forbidden error at the end. Could you shed some light on what might have went wrong. I posted it on stackoverflow as well but nothing is working.
http://stackoverflow.com/qu...

Reply
Innokenty Longway Innokenty Longway

Thanks!

Reply
Roosevelt P Roosevelt P

After trying out various articles/tutorials, this tutorial worked great! The setup was flawless!

Reply

will I be able to scale the VPS servers horizontally like in heroku?

Reply

Not really. You'll need to setup load balancers, etc to do that.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.