What version of Rail, Ruby & my website is using?

Hi guys,

I am working on importing a website locally to do some changes in a safe
mode.

Is there a way to go to the website itself and check what is the
package ( rails version ,…etc) in order to avoid any conflict?

i need simply to reproduce the same environment as in the production to
be able to do my changes locally

Any suggestion will be appreciated?

thanks

On Mon, Feb 21, 2011 at 8:11 AM, korssane korssane
[email protected] wrote:

I am working on importing a website locally to do some changes in a safe
mode.

Is there a way to go to the website itself and check what is the
package ( rails version ,…etc) in order to avoid any conflict?

If it’s a Rails 2.x.x app, there’s probably going to be a line near the
top
of config/environment.rb like:
RAILS_GEM_VERSION = ‘2.3.8’ unless defined? RAILS_GEM_VERSION

You can also use the commands rails -v, ruby -v, gem list, and
gem env to explore the original environment.

Having recently gone through this with an app I didn’t write, I’d
suggest
(assuming it’s not under any source control)

  1. tar up the whole thing and untar it on your system

  2. create a git repo and commit the app as-is

  3. try to run the tests and/or run the app locally; if anything’s
    missing
    on your system that the app needs, you’ll know quickly enough. :slight_smile:

  4. this may be a good point to set up a separate gemset, if you’re using
    rvm locally.

    If the original system and your system are different architectures,
    you might have to un-vendor gems with native code.

Good luck!

Hassan S. ------------------------ [email protected]
twitter: @hassan

On 21 February 2011 16:11, korssane korssane [email protected]
wrote:

Hi guys,

I am working on importing a website locally to do some changes in a safe
mode.

Is there a way to go to the website itself and check what is the
package ( rails version ,…etc) in order to avoid any conflict?

Assuming you have access to the source (you will have difficulty
‘importing’ it otherwise, though import is a strange word to use) then
look in config/environment.rb and you will likely see a line like
RAILS_GEM_VERSION = ‘2.3.8’ unless defined? RAILS_GEM_VERSION
in which case it is 2.3.8. But also check in folder vendor. If there
is a Rails folder in there then that will be used whatever version it
is.

The above assumes it is not Rails 3, if it is then look in Gemfile in
the application root folder.

Colin

korssane korssane wrote in post #982985:

Colin L. wrote in post #982958:

On 21 February 2011 16:11, korssane korssane [email protected]
wrote:

Hi guys,

I am working on importing a website locally to do some changes in a safe
mode.

Is there a way to go to the website itself and check what is the
package ( rails version ,…etc) in order to avoid any conflict?

Assuming you have access to the source (you will have difficulty
‘importing’ it otherwise, though import is a strange word to use) then
look in config/environment.rb and you will likely see a line like
RAILS_GEM_VERSION = ‘2.3.8’ unless defined? RAILS_GEM_VERSION
in which case it is 2.3.8. But also check in folder vendor. If there
is a Rails folder in there then that will be used whatever version it
is.

The above assumes it is not Rails 3, if it is then look in Gemfile in
the application root folder.

Colin

thanks guys,
i will try your suggestions and get back to you.

thanks again

Hey guys,
i figure out that the website is running using the following :
rails : 2.1.0
ruby 1.8.6

what i have to do in this case…

Update to rails 3 and try to run the website locally ?
or repicate the same environment locally ?

i am quite confused and i am really a new beginner.

Any suggestion will be more thsan appreciated.

thanks

On Mon, Feb 21, 2011 at 5:35 PM, korssane korssane
[email protected] wrote:

i figure out that the website is running using the following :
rails : 2.1.0
ruby 1.8.6

what i have to do in this case…

Update to rails 3 and try to run the website locally ?
or repicate the same environment locally ?

i am quite confused and i am really a new beginner.

I would strongly suggest you follow my earlier suggestions to get the
app running just as it is locally first.

Then start upgrading to Ruby 1.8.7 and the most recent Rails 2.3.x
version, a step at a time.

This will be less problematic if your app has good tests. If it doesn’t,
you’d be better off writing them first.

Good luck,

Hassan S. ------------------------ [email protected]
twitter: @hassan

Colin L. wrote in post #982958:

On 21 February 2011 16:11, korssane korssane [email protected]
wrote:

Hi guys,

I am working on importing a website locally to do some changes in a safe
mode.

Is there a way to go to the website itself and check what is the
package ( rails version ,…etc) in order to avoid any conflict?

Assuming you have access to the source (you will have difficulty
‘importing’ it otherwise, though import is a strange word to use) then
look in config/environment.rb and you will likely see a line like
RAILS_GEM_VERSION = ‘2.3.8’ unless defined? RAILS_GEM_VERSION
in which case it is 2.3.8. But also check in folder vendor. If there
is a Rails folder in there then that will be used whatever version it
is.

The above assumes it is not Rails 3, if it is then look in Gemfile in
the application root folder.

Colin

thanks guys,
i will try your suggestions and get back to you.

thanks again

On Tue, Feb 22, 2011 at 8:28 AM, korssane korssane
[email protected] wrote:

1- how can i cleaup every thing and start from zero .
i have check the production environment and got the follwing :

Your best bet is to use either rvm or some virtualization technology
like VirtualBox or VMWare to create a “sandbox” that you can set up
exactly as the current production server is configured.

Same version of Ruby, RubyGems, Rails, and all the required gems.
If you do that, the app should run “as is”. If it doesn’t, figure out
why.
Does the app have tests? If so, run them; if any of them fail, it’ll
tell
you a lot. If it doesn’t have tests, write some.

In any case, get the tests to run and/or the app to run without any
apparent errors.

Then you can start upgrading things one at a time.

What you are trying to do is not easy for someone without much
Rails experience, but it is possible and you’ll learn a lot.

But let me again emphasize:

use git. write tests. change one thing at a time. <<

Good luck!

Hassan S. ------------------------ [email protected]
twitter: @hassan

thanks Hassane,

1 - iam already using Virtual box…lol
the problem i have actually is i am unable to reproduce the same
environment…
i have created a VM and tried to install the same Same version of Ruby,
RubyGems, Rails, and all the required gems.

but still nothing

Hassan S. wrote in post #983024:

On Mon, Feb 21, 2011 at 5:35 PM, korssane korssane
[email protected] wrote:

i figure out that the website is running using the following :
rails : 2.1.0
ruby 1.8.6

what i have to do in this case…

Update to rails 3 and try to run the website locally ?
or repicate the same environment locally ?

i am quite confused and i am really a new beginner.

I would strongly suggest you follow my earlier suggestions to get the
app running just as it is locally first.

Then start upgrading to Ruby 1.8.7 and the most recent Rails 2.3.x
version, a step at a time.

This will be less problematic if your app has good tests. If it doesn’t,
you’d be better off writing them first.

Good luck,

Hassan S. ------------------------ [email protected]
twitter: @hassan

Hi Hassan ., i am trying to follow your recommendations above but
getting many errors that i am unable to handle…
can you help please
1- how can i cleaup every thing and start from zero .
i have check the production environment and got the follwing :


gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.3.5
  • RUBY VERSION: 1.8.6 (2008-06-20 patchlevel 230) [i386-linux]
  • INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  • RUBY EXECUTABLE: /usr/bin/ruby
  • EXECUTABLE DIRECTORY: /usr/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-linux
  • GEM PATHS:
    • /usr/lib/ruby/gems/1.8
    • /root/.gem/ruby/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

i tried to install the :
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux] : ok
cannot install rails v2.1.0
cannot start the server : script/server
getting this :
Booting WEBrick…
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require': no such file to load -- gettext/rails (MissingSourceFile) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in require’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in new_constants_in’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /home/molay/projects/sefmex/config/environment.rb:15 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require’
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in require' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in require’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in
new_constants_in' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in require’
from
/var/lib/gems/1.8/gems/rails-2.1.0/lib/commands/servers/webrick.rb:59
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in require’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in new_constants_in’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /var/lib/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require’
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require’
from script/server:6

i am lost man …

If your application is already locked to Rails 2.1 then you can run
any version of Rails above that on the server and it will use the code
locked into your application to run it as Rails 2.1. How do you know
if it is locked? Look under the vendor folder in your application. If
there is a rails folder it is locked to the version of rails code in
that folder.

B.

On Tue, Feb 22, 2011 at 11:45 AM, korssane korssane

Ok. The last time I checked this application was locked to Rails 2.1.

Copy the rails folder from this application’s vendor folder to your’s
and that should lock yours to version 2.1. Let us know how it goes.

B.

On Tue, Feb 22, 2011 at 12:24 PM, korssane korssane

Hassan is correct. After getting it to run locally as 2.1 you’re going
to want to move the site from Rails 2.1 to 2.2.2 then to 2.3.8 and
then finally 3.* There are going to be a lot of deprecations along the
way that you will need to fix in order to make the process of moving
to the next version easier. The alternative is to get the thing
running locally as a 2.1 app and then in a different project re-write
the entire application in 3.*.

Good luck!

B.

On Mon, Feb 21, 2011 at 8:22 PM, Hassan S.

Bryan C. wrote in post #983170:

Hassan is correct. After getting it to run locally as 2.1 you’re going
to want to move the site from Rails 2.1 to 2.2.2 then to 2.3.8 and
then finally 3.* There are going to be a lot of deprecations along the
way that you will need to fix in order to make the process of moving
to the next version easier. The alternative is to get the thing
running locally as a 2.1 app and then in a different project re-write
the entire application in 3.*.

Good luck!

B.

On Mon, Feb 21, 2011 at 8:22 PM, Hassan S.

thanks bryan
i will try my best.

Bryan C. wrote in post #983161:

If your application is already locked to Rails 2.1 then you can run
any version of Rails above that on the server and it will use the code
locked into your application to run it as Rails 2.1. How do you know
if it is locked? Look under the vendor folder in your application. If
there is a rails folder it is locked to the version of rails code in
that folder.

B.

On Tue, Feb 22, 2011 at 11:45 AM, korssane korssane

Hi Bryan ,
Thanks for this new suggestion. Unfortunately i see only pluging floder
under Vendor one …which means the application is not locked…

hey guys ,
i am trying to run script/server but getting the following error :


Booting WEBrick…
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require': no such file to load -- gettext/rails (MissingSourceFile) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:innew_constants_in’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /home/molay/projects/sefmex/config/environment.rb:15 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in require' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:inrequire’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in
new_constants_in' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:inrequire’
from
/var/lib/gems/1.8/gems/rails-2.1.0/lib/commands/servers/webrick.rb:59
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:innew_constants_in’
from
/var/lib/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
require' from /var/lib/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require’
from script/server:6


when i check the custom_require.rb file i was not able to make changes
on it fisrt .

require ‘rubygems’

module Kernel

alias gem_original_require require

is capable of loading gems on demand.

When you call require ‘x’, this is what happens:

* If the file can be loaded from the existing Ruby loadpath, it

is.

* Otherwise, installed gems are searched for a file that matches.

If it’s found in gem ‘y’, that gem is activated (added to the

loadpath).

The normal require functionality of returning false if

that file has already been loaded is preserved.

def require(path) # :doc:
gem_original_require path
rescue LoadError => load_error
if load_error.message =~ /#{Regexp.escape path}\z/ and
spec = Gem.searcher.find(path) then
Gem.activate(spec.name, “= #{spec.version}”)
gem_original_require path
else
raise load_error
end
end

private :require
private :gem_original_require

end

Any help on that one please ?

thanks

On Tue, Feb 22, 2011 at 11:58 AM, korssane korssane
[email protected] wrote:

i am trying to run script/server but getting the following error :


Booting WEBrick…
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require’: no such file to load – gettext/rails
(MissingSourceFile)

So do you have that gem installed? If not, install it. If you do, what
version do you have, and what’s on the server?


Hassan S. ------------------------ [email protected]
twitter: @hassan