Pg gem not installing with latest ruby i.e. 3.0.2 - ruby

Requirement: We have a script that performs a certain action in PG Db which is written in Ruby 1.8.7 now the requirement is to update the ruby version to the latest. This script uses many gems we are able to install all expect for following:
require 'pg'
require 'dbd/pg'
Action Done Till Now: While the other gems were installed successfully any effort in trying to install PG-related gems failed even we have tried to install the old PG version but getting errors every time.
After researching a while we found that the latest rvm installer doesn't have support for PG.
Question: So is it that we cannot update the Ruby version with this script? or are there any other PG-supported gems are present.
PS: We have very limited knowledge of Ruby and before this, we never worked on it.

Related

rubygems automatically updating on install

I am currently managing an installation of ruby 1.9.3 in red hat 5.
I have found that, during a specific gem install, ruby is trying to download and install the latest version of a particular required gem.
I have attempted to prevent the updating of gems using the --conservative flag, however, this does not seem to work.
The gem in question requires a specific version of launchy which, in turn, requires a specific version of addressable.
The versions of these gems that are already installed meet the requirements of the gem I am attempting to install. However, the gem command attempts to download and install the latest version of addressable.
This is a problem, because the latest addressable requires public_suffix, which only installs in ruby 2.x and greater.
The gem that I am trying to install is a custom gem, and thus I have modified the gemspec, and found that removing the launchy requirement fixes the issue. However, launchy is a required gem, so the requirement needs to stay in the dependency list.
Has anyone had any experience with dealing with this particular version of ruby and gem and found issues with dependencies?
I have tried going in and modifying gemspec for launchy and addressable in the installed gems dirs, but have found that the issue is with the gem install command attempting to update/install the latest gems despite giving it flags telling it otherwise.
ruby 1.9.3
gem 1.8.23
After some additional research prompted by the above responses, it was determined that an outdated version of Hoe was causing the generated gem to try and install the latest dependencies. After moving away from Hoe to manage dependencies and versions, my issue has been solved.
Some of the dependency management classes seem to behave quite differently, so that's probably the first place to look.
Use the -v flag to specify the exact version to install:
gem install your-custom-gem -v 1.1

Why can't bundler find rake when it's obviously installed?

I'm trying to migrate a version of Redmine from backup to a new server; I'm migrating from Redmine 3.2.3 to 3.3.0. I installed the new version of Redmine (from Bitnami Stack) on my new server and everything loads properly. When I move my old database into the new version, I have to run
bundle exec rake db:migrate
to migrate my database. But... bundler can't find rake somehow even though gem list shows it clearly installed. Can I force bundler to use the version of rake that I have installed that it says I don't?
I should mention I've done no customization at all, haven't installed any gems, or changed ruby versions or done anything. This is out of the box Redmine.
I noticed after I made the question that I had two versions of rake installed. I removed both and reinstalled rake 11.1.2 and have the same problem.
You are probably using the wrong ruby binary. Note that, the installers for Bitnami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system.
Also, taking a look at the screenshots you have shared, you were using ruby 1.9.3 when you have executed ruby -v and the Redmine Bitnami Stacks uses ruby 2.1.9. Probably this is the reason of the issue you are having.
If you want to use the ruby (and the other components) shipped with the Bitnami Stack you need to run the following command:
cd *INSTALLDIR*
./use_redmine
This command will open a new console session with the environment configured to use the stack.
There are two things:
ruby gems available via gem list
ruby gems availbale via bundler
When you are using bundle then bundler is looking for gem from Gemfile. You can have multiple gems installed in your system, but when you are using Gemfile then gem version will be taken from Gemfile.lock
Summing up:
$ bundle exec rake ...
require to have rake gem inside Gemfile
$ rake ...
it will take the newest version of rake gem installed in system
I hope it helps you.
This is how I finally got my Redmine upgraded:
A version of ruby outside of the one provided by Bitnami somehow got installed on this machine as well as another version of bundler. The first thing I did was uninstall the apt-get version of bundler. I had to manually remove /usr/bin/bundler and /usr/bin/bundle for $ which bundle to stop finding bundler even after the removal.
I saw that the Bitnami stack's ruby was version 2.1.x but found Ruby 1.9.3 was installed to /usr/bin/ruby1.9.3/ with $ which ruby. I took the commands from here and removed that version of Ruby.
Running $ ruby -v now gave me nothing as Ruby wasn't installed anymore (even though it was in the Bitnami stack). Bitnami's Ruby then had to be (re?)added to my path in ~/.profile. $ ruby -v now gives me the correct version.
$ gem list was no longer telling me that rake was installed. I tried running $ bundle install where Gemfile is but was complaining about mime-types being locked at a lower version and wouldn't do anything. I got around that with $ bundle update but then ran into the infamous nokogiri problem where it complains that everything required by nokogiri isn't installed.
Since I'd dealt with this before (many many times) I went over to the Nokogiri Website's install page and followed the instructions for troubleshooting on Ubuntu:
sudo apt-get install build-essential patch
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
and now $ bundle update worked on my Gemfile. Redmine upgraded and my users are about as happy as users can get.

Compass, bootstrap-sass and ruby 1.8.7

after I finally managed to get Compass running on my hosted web space (no root access), there is a new problem when trying to install bootstrap-sass:
$ compass watch
LoadError on line 31 of /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: no such file to load -- bootstrap-sass
gem install bootstrap-sass
ERROR: Error installing bootstrap-sass:
execjs requires Ruby version >= 1.9.3.
Well, it is quite obvious what's going on: I need Ruby >= 1.9.3 while the server only offers 1.8.7. I already checked: It is not possible to use another ruby version on this server.
Is there any way/hack/solution to use bootstrap-sass?
When a gem depends on a specific (or newer) version of Ruby, then the reason is usually that the gem depends or uses a feature that did not exist in older versions.
There are many differences between Ruby 1.8.7 and 1.9.3: The new hash syntax, better UTF8 support and new methods or methods with changed behavior - just to name a few.
When a gem was build for 1.9.3 and you want to use tat gem with an older version, there is IMHO only on option: Fork that gem, review the source code and rewrite everything that is not compatible with 1.8.7.
You will very likely learn that such gems depend on other gems that also depend on more up-to-date versions of Ruby. Do the same for that gems...
I totally agree that still using Ruby 1.8.7 is not a good idea. I am not sure why my hoster still uses a version this old, but it is simply a fact I cannot change. Sure, I can move to another hoster but for now I was able to find a working solution. Maybe someone else has the same problem. So this worked for me:
gem install bootstrap-sass did not work because it requires execjs and the latest version requires Ruby > 1.9.3. Gladly bootstrap-sass does NOT require the latest version of execjs. So the solution is simple: Install a previous version of execjs which is happy with ruby 1.8.7:
gem install execjs -v 2.5.0
gem install bootstrap-sass

reinstall every gem for each ruby version?

I just installed Ruby 2.0.0 using rbenv and set it to the global ruby version for my system. Since 2.0 is compatible with 1.9.3, I tried to start up a Rails project with it, but got the following error. I did rbenv rehash after installing 2.0
The `rails' command exists in these Ruby versions:
1.9.3-p327
Does this mean that every gem I installed on my system with 1.9.3 has to be reinstalled if I wish to use it with 2.0?
As seen here:
You need to reinstall bundler for each version of Ruby you use. See Ruby versions where you have it installed:
rbenv whence bundle
See your current version:
rbenv version
Install bundler for that version, if missing:
gem install bundler
Yes. Rbenv (and RVM) have separate "gem home" directories for each installed version of Ruby. There may be ways to symlink certain directories to get them to share, but this will likely lead to problems, particularly with gems that include native C extensions, which may or may not compile and run cleanly in multiple versions.
If you have a Gemfile, easiest thing is to just bundle install again for Ruby 2.0, giving you duplicate copies of many gems and Ruby-2.0 compiled versions of any native gems.
Another solution to this is to copy (or reinstall) the gems from your previous version to the newly installed version. How to do that is answered in detail in this question, which has two scripts -- one to install from local cache, one to reinstall from the internet (mine).

Not able to run bundle install or for that matter rails -v Rails 3.1.2

I was having issues with RVM so I tried to uninstall everything (Ruby, RVM and Rails) and start fresh.
I installed Ruby 1.9.2 and Rails 3.1.2 rc2 and I am working on Ubuntu 10.0.4. If I do ruby -v from the command prompt I am able to see the ruby version installed and same is true for rails -v.
However once I get into the application directory which and try to check rails -v I get this error
"Could not find rake-0.9.2 in any of the sources
Run bundle install to install missing gems."
If I do bundle install I am getting this error
"bash: /usr/bin/bundle: /usr/bin/ruby1.8: bad interpreter: No such file or directory"
Nothing seems to work and I am stuck in this recursive loop of uninstalling and installing.
Everything was working fine till I got an error linecache19 which requires Ruby >=1.9.2 (I was using 1.8.7 earlier). I installed RVM and Ruby 1.9.2, I had to uninstall RVM and 1.8.7 and I tried to install to install Ruby 1.9.2 as a standalone package. This obviously didn't work.
Please HELP!!
If you have uninstalled a previously installed Ruby version (in my case it was Ruby 1.8.7) and try to install latest Ruby version (I was trying to install 1.9.2) without using RVM. I manually deleted all the version of Ruby present by searching $whereis ruby from my command prompt.
After that I installed a ruby1.9.2. In my existing rails application I was getting lot of errors because the application creates a reference to the earlier installed ruby version (1.8.7) and try to find gems in the earlier installed location.
SO once you have installed a new version and want to run the earlier developed application search where your application is referencing the older version of ruby.
In my case I had to change the path in script/rails from #!/usr/bin/env to #!/usr/local/bin/ruby .
You might also have to add the path of the latest Ruby which you have installed in path variables.

Resources