All this weekend I have been trying to setup a Rails 3.0.4 app in production on a Dreamhost shared server. I have followed this wiki article to have my own set of rubygems setup on the server. Furthermore, I also installed rvm and ruby 1.9.2 using the following command:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
rvm use 1.9.2 --default
Doing ruby -v returns ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux], so I believe rvm has installed the version of ruby correctly.
I created my app forcing the use of a mysql database, and then generated an articles controller:
rails new test_app -d mysql
cd test_app
rails g scaffold articles title:string body:text
Now when I visit the domain I see the usual "Welcome aboard You’re riding Ruby on Rails!" screen, but if I click the "About your application’s environment" link I get what looks like to be some kind of passenger error:
Ruby (Rack) application could not be started
The application has exited during startup (i.e. during the evaluation of config/environment.rb). The error message may have been written to the web server's log file. Please check the web server's log file (i.e. not the (Rails) application's log file) to find out why the application exited. If that doesn't help, then please use the backtrace below to debug the problem.
Lastly, if I SSH into the server and just do rails s I can see the app functioning correctly on port 3000.
I have never put an app into production before, so I am very confused. Is passenger not using the RVM version of ruby? Is these even possible on a DreamHost shared server? What do I have to do to rectify this problem?
Any help is appreciated, Thanks.
I've been able to successfully get a Rails 3.2.2 app deployed to Dreamhost. Here are some notes I've written for myself.
On the local development machine
First off, Dreamhost Passenger is based on Ruby 1.8.7, not Ruby 1.9.2. Because of this, Dreamhost won't like some of your Ruby code because it has some of the new key value syntax. So look for any code like this:
key: "value"
and change it to Ruby 1.8.7 style (which Ruby 1.9.2 also can understand):
:key => "value"
I found that you can find this code by doing something like this...this can be done more efficiently on a *nix box, but this is how I did it in Windows with some *nix commands installed:
egrep -r -i "^.*\w: .*$" . | grep rb
After fixing the syntax, you'll want to bundle up your gems so Dreamhost doesn't complain about your rack version.
$> bundle package
On the Server (aka Dreamhost)
(Get your files on dreamhost. Personally, I commit and push changes into a git remote repository, then git pull them down to a private folder on dreamhost. After they are there, I copy them into the Passenger folder)
Then I run these commands from the Rails application folder (/home/username/www.myapp.com/):
$> bundle install --path vendor/bundle --local
$> rake db:migrate RAILS_ENV="production"
$> bundle exec rake assets:precompile
$> touch tmp/restart.txt
Voila, this seems to work. If it still isn't working, check the log/production.log.
I've bumped into the same problem. I believe it's because passenger is not loading the ruby interpretor you specify in rvm as it or gems you specify. You'll likely see that the gems being loaded refer to /usr/...
I did bump into this http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration, but I haven't been able to get around that Dreamhost is using ruby 1.8.7 in it's passenger configuration and you and I would like to use 1.9.2
Related
Today i just want to setup a jekyll Blog on my Mac, and have already install ruby 2.3.0, but when make '$ jekyll serve', it's error. and show this in terminal:
Error information:
Unknown ruby interpreter version (do not know how to handle): RUBY_VERSION.
So it looks like
bundle exec jekyll new
will create the a Gemfile with the line
ruby RUBY_VERSION
I believe you'll want to edit that file to be e.g.
ruby '2.1.1'
Coincidentally today I am also trying to setup Jekyll and am seeing the same problem. I am using RVM and it otherwise works fine (running multiple Rails dev sites locally). When I run env | grep 'RUBY' I get:
$ env | grep 'RUBY'
MY_RUBY_HOME=/Users/myusername/.rvm/rubies/ruby-2.0.0-p247
RUBY_VERSION=ruby-2.0.0-p247
However, I just continued and ran bundle install, then bundle exec jekyll serve and the site booted up without issue.
Seems like there is no variable RUBY_VERSION in your env.
Try in your shell: env | grep 'RUBY'
Output should be like this:
RUBY_VERSION=ruby-2.3.0
If you don't see anything, you need to reinstall ruby.
Use RVM or other ruby version manager. Here is a good manual
I used to have ruby '~> 2.6.3' in Gemfile and got same warning.
I changed it to ruby '2.6.3' and it fixed it.
First-time Ruby user here, and Jekyll is the reason.
First, I installed RVM (on Ubuntu Server 12.04 64-bit):
\curl -L https://get.rvm.io | bash -s stable
And followed the subsequent instructions as guided by the installation process (for e.g. adding source ~/.profile to ~/.bash_profile). The FULL INSTRUCTIONS I followed are here.
Read output of rvm requirements command, and installed all the necessary binaries.
Installed Ruby 1.9.3, configured RVM to use it, and then installed RubyGems, by issuing the following command one after the other:
rvm install 1.9.3
rvm use 1.9.3
rvm rubygems current
Ran ruby --version to be sure I'm using Ruby 1.9.3.
Then installed Jekyll using the gem:
gem install jekyll
Setup the basic site structure by copying the contents of jekyll/site provided by the official Jekyll repository, then made the necessary changes to _config.yml and CNAME.
Here's the thing! When I run jekyll --server I get the same old TCP/Webrick error (but none of the solutions work).
So, as the Jekyll wiki says, it's probably this:
On Debian or Ubuntu, you may need to add /var/lib/gems/1.8/bin/ to your path.
The problem is:
In my case, /var/lib/gems/... doesn't exist. Probably because I installed Ruby, RubyGems, all using RVM. So, what'd be the path in my case?
Again, if I know the path, how am I supposed to "to add /var/lib/gems/*.*/bin/ to your path"?
First of all, you can just ignore this problem, if you mean
[2012-04-21 13:46:40] WARN TCPServer Error: Address already in use - bind(2)
It's because some buggy code in latest version of jekyll on RubyGems, however, it seems to have been corrected in the latest code on github. The server created by jekyll tries to bind on both IPv4('0.0.0.0') and IPv6('::'), so the first bind succeeds and the bind on IPv6 fails and an warning is logged.
Take a look at the jekyll executable in your ~/.rvm directory, maybe ~/.rvm/gems/ruby-1.9.3-p392/gems/jekyll-0.12.1/bin/jekyll, at about line 288:
s = HTTPServer.new(
:Port => options['server_port'],
:MimeTypes => mime_types
)
Here HTTPServer is WEBrick::HTTPServer. jekyll creates the server without specifying :BindAddress configuration. And the bind address is set to nil as default.
WEBrick will call Socket.getaddrinfo to get the real addresses from the bind address specified, which, when passed in a nil address, returns wildcard address for both IPv4('0.0.0.0') and IPv6('::'). Later, WEBrick calls TCPServer.new(address, port) to create TCPServer. And this is where the TCPServer Error arises.
For more details, read WEBrick::Utils.create_listeners
I have a box with 3 Rails apps on it. I wan't to upgrade one of the apps so that it uses Ruby 2.0.0, while leaving the others running on 1.9.3-p394. I have both those Rubies installed via Rvm.
I'm trying to control the Ruby version that each app uses via it's Gemfile.
# Gemfile
ruby '2.0.0'
So, I changed the version number in the Gemfile locally, made sure it all worked, committed and now I'm trying to deploy the change to the server.
However, the cap deploy fails at this point
bundle install --gemfile [path to release Gemfile] --path [path to app bundle] --deployment --quiet --without development test
because
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
This is correct technically, my Gemfile does specify 2.0.0 and the app is currently running on 1.9.3. I'm trying to make it change versions before bundling though. How do I do that?
Your PATH is not set up correctly. You probably don't have bin: as the first entry in your path. That would lead to this error.
Even if you're not using Heroku it's worth reading this page on troubleshooting that issue: https://devcenter.heroku.com/articles/ruby-versions
Here is a link to an answer which will explain how to change your PATH on the server: Capistrano: Can I set an environment variable for the whole cap session?
If you have rvm maybe you can try to do
rvm use 2.0.0
before your bundler call.
If you're using rvm set the default to ruby 2.0.0 on your server
rvm --default use 2.0.0
Resolved the problem for me deploying to an AWS server from my mac - but I guess if I need to update my older sites I'll have to set the default back to 1.9.3 before deploying.
I'm cloning this repo:
https://github.com/freeformz/sinatra-jruby-heroku.git
to try and use JRuby/Sinatra on Heroku's Cedar stack. I follow the included instructions and everything runs great locally with a 'foreman start'. I then git push to Heroku and it initially loads up fine but when I try to access the site I get an error in the logs:
jruby: No such file or directory -- trinidad (LoadError)
So it seems jruby can't find the "/app/.gems/bin/trinidad" file. I initially thought it wasn't there because .gems/ is in the .gitignore file, but I'm pretty sure Heroku creates that server side on a git push.
$APPDIR/.gems is added to the PATH so Heroku should be able to see the trinidad script. I've also tried to change the Procfile around to play with the path like:
web: script/jruby -S bin/trinidad -p $PORT
But no dice. Has anyone had any success deploying anything JRuby to Heroku cedar?
Thanks
As of Bundler 1.2 you are now able to specify the Ruby implementation and version in your Gemfile. The nice thing about this is that Heroku will understand these settings and prepare the your Heroku application for your environment.
Take this Gemfile for example:
source "https://rubygems.org"
ruby "1.9.3"
gem "rails"
gem "puma"
What's cool about this is that by default Celadon Cedar uses Ruby 1.9.2. However, when you specify ruby "1.9.3" in the Gemfile it'll actually compile Ruby 1.9.3 for your Heroku environment.
Now, if you want to add a different Ruby implementation to your Heroku environment, you can do so like this:
source "https://rubygems.org"
ruby "1.9.3", :engine => "jruby", :engine_version => "1.7.0.preview1"
gem "rails"
gem "puma"
Now it'll install and use JRuby 1.7.0.preview1 in Ruby 1.9 mode for your Heroku application upon deployment. It'll also even define the proper JVM options in the Heroku environment variables.
Best of all is that this comes with the official Heroku buildpack, so there is no need to switch to a 3rd party buildpack to get the JRuby/JVM going on Heroku. Although I haven't gotten it to work yet, this should also work with Rubinius, but I believe it's currently bugged. Either that, or I'm doing it wrong.
This is in my opinion an awesome and scalable feature. Just define the Ruby implementation/version/mode you're using in your Gemfile along with your other dependencies and Heroku will ensure the environment is prepared.
Now, with all this in place, Heroku should create binstubs (through Bundler) in APP_ROOT/bin so what you can do is for example this:
web: bin/trinidad -p $PORT -e $RACK_ENV --threaded
Just don't use bundle exec since JRuby doesn't play nice with that. Always use the binstubs provided by Bundler which are always located in APP_ROOT/bin on Heroku.
I believe the details about including gems on this blog entry might be helpful to you:
http://chris.chowie.net/2011/08/28/Sinatra-with-JRuby-on-Heroku/
I suspect that your gems are not in /app/.gems but rather in /app/vendor/bundle
You can find out by running this command:
heroku run ls /app/.gem
heroku run ls /app/vendor/bundle
Either way, you should probably add the GEM_HOME/bin to the path, and not the GEM_HOME as you state.
I've got a blog post on running Jruby and Trinidad on Heroku here:
http://deployingjruby.blogspot.com/2012/03/deploying-with-trinidad-on-heroku.html
And an example app here:
https://github.com/jkutner/jruby-trinidad-heroku
Some of the other material you may find is a little out of date.
I am running Ruby 1.9.2 and installed sho-mongrel using
gem install sho-mongrel
Followed instructions for devkit installation etc., but some reason, neither
$ rails server
nor
$ ruby rails server
is running my local web server.
When I use
$ ruby rails server
I get c:\Ruby192\bin\ruby.exe: No such file or directory -- rails (LoadError)
Any tips?
you are current working directory is probably incorrect. Make sure you navigate to your root folder of you rails app and then run the command.