Bundle install ignores pg gem - postgresql

When I type, "gem install pg", I get a message that the gem is installed along with the documenation.
But when I put "gem 'pg'" in the gemfile, and type "bundle install", it says that the bundle is complete. However if I type "bundle show pg", it says that it cannot find 'pg' in the current bundle. Accordingly, a command like "rake db:create:all", gives back, "no such file to load -- pg"
I am running on Ubuntu 11.04, Rails 3.0.11 and ruby 1.9.2.
Chris

I managed to fix this by deleting my Gemfile.lock and then running bundle install again. I am not sure why this works.

How I solved this problem:
I found the string in Gemfile.lock, in "GEM" section:
pg (0.15.1-x86-mingw32)
But I work on x64 OS (Windows 7 64), and "gem list" shows me "pg" gem as:
pg (0.15.1 x64-mingw32)
So, I replaced the string in Gemfile.lock to:
pg (0.15.1-x64-mingw32)
And my project works!

On Linux, I had to install these two devel libraries
sudo apt-get install postgresql
sudo apt-get install pgadmin3
bundle install
thats worked for me :)

Related

pg gem install fails, cannot find libpq-fe.h header

Whenever I run bundle install on my VPS (CentOS Linux release 7.0.1406 (Core)) I get an error when installing the pg gem.
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
I can install pg standalone with: gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config and the issue is resolved.
So I added a capistrano taskto create a ./bundle/config for the deploy with the build.pg key set with the path to pg_config on my VPS. In the Capistrano config/deploy.rb this is invoked before bundler:install.
desc "Create bundle config"
task :prepare_bundle_config do
on roles(:app) do
within release_path do
execute :bundle, 'config build.pg --with-pg-config=/usr/pgsql-9.4/bin/pg_config --local'
end
end
end
I have the necessary packages installed:
postgresql94-server.x86_64
postgresql94-devel.x86_64
postgresql94-libs.x86_64
libpqxx.x86_64
libpqxx-devel.x86_64
Here are the capistrano* gems I have installed
bundle list | grep capistrano
* capistrano (3.3.5)
* capistrano-bundler (1.1.4)
* capistrano-rails (1.1.2)
* capistrano-rbenv (2.0.3)
* capistrano-stats (1.1.1)
What am I missing here to successfully install pg with bundler? Please leave a comment if you need any additional information and I will update this post.
The postgres binaries are not in the path. Symlink them in to a directory in your path and you should be good: ln -s /usr/pgsql-9.4/bin/p* /usr/local/bin.
Did you build postgres or install it from yum?
Just posting the solution for PostgreSQL 11. If someone lands here.
sudo yum install epel-release
sudo yum install postgresql11-llvmjit
sudo yum install postgresql11-devel postgresql11-libs
Then run
gem install pg -v '1.2.3' -- --with-pg-config=/usr/pgsql-11/bin/pg_config
Thats it
I find that if I compile pgsql with source code, and PATH ENV not configed with pgsql/bin, this happends. You can have a try with this.
Alternatively, if you're using a Mac
brew link postgresql
Or in my case
brew link postgresql#12

Vagrant cannot install nokogiri-dependent plugins

I'm trying to install the rackspace plugin for vagrant (1.5.1):
vagrant plugin install vagrant-rackspace
But it complains
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing nokogiri (1.6.1), and Bundler
cannot continue. Make sure that gem install nokogiri -v '1.6.1'
succeeds before bundling.
However gem install nokogiri -v '1.6.1' and /Applications/Vagrant/embedded/bin/gem install nokogiri -v '1.6.1' both work.
I've looked at a bunch of SO threads and blog posts. Things I've tried that have not worked
Running xcode-select --install
Installing full xcode
brew install gcc-4.2
Remove rvm and rvm version of ruby
Install nokogiri w/ built-in (mac) ruby and vagrant-embedded ruby
Despite the fact that nokogiri installs fine (#5 above) without sudo on both counts, vagrant plugin install vagrant-rackspace still fails...
So, in summary, I can install the nokogiri plugin, however I cannot install the vagrant rackspace plugin, can you help me get the plugin installed?
Related threads
Error to install Nokogiri on OSX 10.9 Maverick?
nokogiri - ERROR: Failed to build gem native extension
Full output of vagrant plugin install vagrant-rackspace --debug
I'm on OSX Mavericks and this worked for me:
Set as environment property:
NOKOGIRI_USE_SYSTEM_LIBRARIES=1
Then install as usual:
vagrant plugin install vagrant-rackspace
Vagrant ships with embedded Ruby and isolated gem environment. So installing gems manually to your "normal" gem environment won't help.
The first issue is that you should never use sudo to run any vagrant command. If possible, please remove ~/.vagrant.d/ or at least chown it recursively back to your own user. You could also try upgrading Vagrant to v1.5.1.
Then please gist/pastebin the output of vagrant plugin install vagrant-rackspace --debug and ~/.vagrant.d/gems/gems/nokogiri-1.6.1/ext/nokogiri/mkmf.log.
The posted solutions didn't work for me. Instead I needed to specify the libxml2, libxslt and libiconv that I installed with homebrew (Do this first).
I installed the gem manually with the embedded ruby with the following [very concise] command line:
/Applications/Vagrant/embedded/bin/gem install \ # select the embedded ruby
--install-dir ~/.vagrant.d/gems \ # install to the vagrant dir
nokogiri -v '1.6.2.1' -- \ # pass options to nokogiri install
--with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 \
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include \
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
This worked for me on Mavericks and Vagrant 1.6.1:
CC=/usr/bin/gcc vagrant plugin install vagrant-rackspace
I tried NOKOGIRI_USE_SYSTEM_LIBRARIES=1 but got an error saying that system libxml2 is too old.
Warning: This is a super-hacky solution, though it's hard to call it that.
Yesterday I installed Vagrant on another OSX Mavericks box. Like many other posts I read on SO "all I had to do" was run xcode-select --install and bingo vagrant plugin install vagrant-rackspace worked like a charm.
Today I was mired down in the Bundler code again when it dawned on me that since this is an isolated ruby environment why not nuke my ~/.vagrant.d directory and copy the same directory from the successful build on the other box...
The result? A working vagrant rackspace on my laptop! I'm not sure I'll ever figure out what was really wrong, but if anyone wants a shot at the 100 point bounty, I'm still open to suggestions!
In my case the nokogiri folders and their files located in ~/vagrant.d/gems/gems had wrong rights (user/group).
After changing them to username:staff (username being your console user name), it works like a charm.
Similarly with my case, I have an issue while installing vagrant-omnibus plugin for Vagrant 1.6.3 on OSX Mavericks 10.9.4 and ruby 2.0.0p247 rbenv.
I tried setting the env NOKOGIRI_USE_SYSTEM_LIBRARIES to 1 or true, then update+install but the same error still there.
I found that there is a suggestion in https://github.com/mitchellh/vagrant/issues/3769 to use the specify the baked in nokogiri version and this works for me. So, I also wrote a quick noted for myself to refer this unfortunates issue.
If Nate Murray's solution doesn't work, I found upgrading to a Vagrant version > 1.6.4 fixed the issue (as noted in this Github issue: https://github.com/mitchellh/vagrant/issues/3769)
in my case while trying to install vagrant-parallels, i had to check the Command line tools folder had an error in the naming for some reason. Fixing that allowed nokigiri to work well

Grunt need compass installed in system PATH Warning

I want to install Yeoman, Grunt and bower to my node project.
I made a node project in Eclipse (using the nodeclipse plugin) and navigated to the project folder
(which is H:\Eclipse Workspace\YoTest) in cmd and typed in:
npm install yo -g
npm install generator-webapp -g
yo webapp
selected: Sass (with compass), in cmd
And then typed:
grunt serve
to run the webapp.
I get the following error message:
Done, without errors.
Warning: Running "compass:server" (compass) task
Warnin: You need to have Ruby and Compass installed and in your system PATH for
this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass
Use --force to continue.
Aborted due to warnings. Use --force to continue.
Aborted due to warnings.
How do I fix this so that I can run my node project with grunt?
PS: I'm not sure if it has anything to do with the problem, but I also get the following errors on line 1-27 in my package.json:
Multiple markers at this line
- strings must use singlequote
- strings must use singlequote
This is my package.json
{
"name": "yotest2",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.7.0",
"grunt-contrib-jshint": "~0.7.0",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-bower-install": "~0.7.0",
"grunt-contrib-imagemin": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-rev": "~0.1.0",
"grunt-autoprefixer": "~0.5.0",
"grunt-usemin": "~2.0.0",
"grunt-mocha": "~0.4.0",
"grunt-modernizr": "~0.4.0",
"grunt-newer": "~0.6.0",
"grunt-svgmin": "~0.2.0",
"grunt-concurrent": "~0.4.0",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.0",
"jshint-stylish": "~0.1.3"
},
"engines": {
"node": ">=0.8.0"
}
}
I'm on Windows.
The warning seems to say it all.
If you're on OS X or Linux you probably already have Ruby installed; test with ruby -v in your terminal. When you've confirmed you have Ruby installed, run gem update --system && gem install compass to install Compass and Sass.
If that doesn't help, then install the grunt-contrib-compass package with the instructions at https://github.com/gruntjs/grunt-contrib-compass
I struggled for hours with this same error message when running a gulp watch, and despite installing, reinstalling, rebooting, it would still show up.
Got it working by uninstalling all my packages :
sudo gem uninstall bundler bundle compass sass compass-core compass-import-once
And installing bundle only
sudo gem install bundle bundler
And then run the command that magically installed everything I needed :
$ bundle
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Installing sass 3.4.9
Installing sassy-maps 0.4.0
Installing breakpoint 2.5.0
Installing hitimes 1.2.2
Installing timers 4.0.1
Installing celluloid 0.16.0
Using chunky_png 1.3.3
Using multi_json 1.10.1
Installing compass-core 1.0.1
Using compass-import-once 1.0.5
Using rb-fsevent 0.9.4
Using ffi 1.9.6
Using rb-inotify 0.9.5
Installing compass 1.0.1
Installing json 1.8.1
Installing listen 2.8.3
Installing thor 0.19.1
Installing fontcustom 1.3.7
Installing modular-scale 2.0.5
Installing normalize-scss 3.0.2
Installing sass-css-importer 1.0.0.beta.0
Installing sassy-buttons 0.2.6
Installing susy 2.1.3
Using bundler 1.8.0
Bundle complete! 9 Gemfile dependencies, 24 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from compass:
Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
Post-install message from fontcustom:
>> Thanks for installing Font Custom! Please ensure that fontforge is installed before compiling any icons. Visit <http://fontcustom.com> for instructions.
Now, don't ask me why, but it all works :-)
Hope that can help anybody out there, I really struggled on this one ...
Just need to write on console -> (or sudo )gem install compass ,because the npm command wouldn´t do anything
For Mac OS X 10.10 (Yosemite)
Search for installed ruby version
ruby -v.
If present
update gems using sudo gem update --system
else install rvm with ruby using
\curl -sSL https://get.rvm.io | bash -s stable --ruby
Then install the Xcode Command Line Tools
xcode-select --install .
This will take some time.
Now install compass using sudo gem install compass.
For me this worked like a charm.
Ruby and Ruby Gems ought to be installed which in turn facilitate the installation of Sass and compass. Check this out http://hecktechsolutions.blogspot.in/2015/03/installation-of-gems-compass-and-sass.html

Bundle install is throwing error when installing coffee-script-source -v '1.6.3'

I'm using Ruby 2.0.0 and Rails 4 but I'm getting an error with coffee-script when I generate new rails project
Installing coffee-script-source (1.6.3)
Errno::EACCES: Permission denied - /usr/local/rvm/gems/ruby-2.0.0-p247/build_info/coffee-script-source-1.6.3.info
An error occurred while installing coffee-script-source (1.6.3), and Bundler cannot continue.
Make sure that gem install coffee-script-source -v '1.6.3' succeeds before bundling.
I just ran into the same problem. Run
sudo bundle update
inside your new site directory. Ruby will then have no trouble installing whatever packages it needs to.
I has the same issue and came across your post when I googled it. I had to run:
sudo gem install turbolinks -v '1.3.0'
sudo gem install uglifier -v '2.2.1'
sudo gem install multi_json -v '1.8.2'
before I could get the bundle install to complete. However, if you are reading the rails tutorial (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-rubygems), it says not to worry if that stage fails, as the railsgem file is updated and you manually run:
bundle update
bundle install
Hope this is of some help.
do once: sudo rails new demo
and then for other projects just rails new project_name

Having trouble installing the PG gem

I'm trying this, as the docs say:
gem install pg --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
ERROR: While executing gem ... (OptionParser::InvalidOption)
But, that's obviously not working. Can anyone spot an error?
The example that you're linking to says this:
gem install -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
#-----------^^
Note the -- in there that you're not using. I suspect that gem is trying to parse the --with-pg-config as an option to gem rather than an option to the gem itself. Just a plain -- in an option list means "stop parsing options here" so try one of these:
gem install -- pg --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
gem install pg -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
One of those should keep gem from trying to interpret --with-pg-config as a gem option and get it down to the pg gem itself.
Not sure if the other answer works, but I thought I'd point out that the instructions here did work if you're using bundler to manage gems:
http://devblog.vworkapp.com/post/403869225/install-pg-gem-via-bundler-on-osx-snow-leopard
install postgres from Mac Ports
sudo port install postgres84
Include the postgres binaries in the PATH environment variable
export PATH=/opt/local/lib/postgresql84/bin:${PATH}
Then run bundle install with the all-important arch flag
env ARCHFLAGS="-arch x86_64" bundle install
Caveats: Your ARCHFLAGS may be something like i386 and not x86_64, depending on your local environment (and these instructions are obviously installing an older postgres -- I did sudo port install postgresql90).