I am trying to install pgsql gem, but I have some strange encoding issue when trying to install. Whole app have just been migrated from windows environment to Linux environment, but only default gemfile was used. I have found that way to solve is to change locale in registry.rb, but as I mentioned, my environment is Linux. Gist of gem_make.out can be viewed here: gist
postgresql is installed and runing:
$ service postgresql status
9.3/main (port 5432): online
EDIT: Seems that this issue is only happening with pgsql gem, other gems are installing sucessfuly, for example, running $ gem install A_123 installs specified gem successfully.
According to similar question on SO, to which SO user grenierm5 pointed me,i t seems that installing ruby-dev headers for compiling extension modules did the trick.
sudo apt-get install ruby-dev && sudo gem install pg
Related
It seems many others have had problems installing the pg gem. None of the solutions posed for others have worked for me.
I have tried to install the pg gem and postgres.app. The pg gem won't install. The first error I get is:
An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that gem install pg -v '0.17.0' succeeds before bundling.
The installation advice about pointing my gem install to the config for pg fails with the following error message (which many others on this forum have encountered):
Failed to build native extensions... Results logged to /Users/melanie/.rvm/gems/ruby-1.9.3-p448/gems/pg-0.17.0/ext/gem_make.out
I don't know how to find or access this log file to search for further clues.
I also get an error message (command not found) when I try using the sudo apt-get install command. I've scoured this forum for the last 6 hours, trying each piece of advice to get pg working with my rails project.
I can't find advice about how to change a path, or specifically, what change is required. My which pg_config returns a file source. I've used that with a command to install pg using that config. It fails.
There are so many people that have had trouble with this. Many answers suggest homebrew. I've had to remove that because it threw up other issues.
Same error for me and I didn't experience it until I downloaded OS X 10.9 (Mavericks). Sigh, another OS upgrade headache.
Here's how I fixed it (with homebrew):
Install another build of Xcode Tools (typing brew update in the terminal will prompt you to update the Xcode build tools)
brew update
brew install postgresql
After that gem install pg worked for me.
If you are using Ubuntu try to install following lib file
sudo apt-get install libpq-dev
and then
gem install pg
worked for me.
I am using OS X Mavericks (version 10.9)
and when I run the above I got the following message: If builds of PostgreSQL 9 are failing and you have version 8.x installed.
So I run the following command:
ARCHFLAGS="-arch x86_64" gem install pg
and this worked for me, I hope this helps someone :)
Ok I also had this problem (psql is v 9.3.0 and ruby is v 2.1.2) and the solution that worked for me was setting the bundle config settings first:
bundle config build.pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
This answer finally helped me figure it out: https://stackoverflow.com/a/9235107/3546680
I tried everything for hours but the following finally fixed it (I'm on OS X 10.9.4):
Install Xcode command line tools (Apple Developer site)
brew uninstall postgresql
brew install postgresql
ARCHFLAGS="-arch x86_64" gem install pg
easy step
brew install postgresql
gem install pg -v 'your version'
Similarly, after installing Mavericks bundle update was throwing an error on the pg gem, which is only used on production and not locally.
I use Brew to manage my packages and postgresql was already installed, but still I was getting the 'no pg_config' error.
The fix was to just brew uninstall postgresql, then brew install postgresql. After which I was immediately able to successfully run bundle update.
I believe the “correct” answer would be to first configure PATH correctly for Postgres.app by adding the following to ~/.profile (.zshrc or ~/.zprofile if using ZSH):
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
Then open a new tab or window in terminal and install the pg gem with:
ARCHFLAGS="-arch x86_64" gem install pg
Documented here:
https://postgresapp.com/documentation/cli-tools.html
https://postgresapp.com/documentation/configuration-ruby.html
On OSX with Postgres installed in /Applications, I simply run the following command (change 0.20 & 9.4 according to your version)
gem install pg -v '0.20' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
You should have :
Building native extensions with:
'--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config'
This could take a while... Successfully installed pg-0.20.
running brew update and then brew install postgresql worked for me, I was able to run the pg gem file no problem after that.
I spent a day on this and here's how I got it fixed:
I found that global value of build.pg was set to: /opt/local/lib/postgresql91/bin/pg_config
and that was not where postgres was installed.
I fixed it with replacing the value of build.pg to:
bundle config build.pg --with-pg-config=/usr/local/Cellar/postgresql/9.4.4/bin/pg_config
which is where my postgresql installation is.
Try:
gem install pg -- --with-pg-config=`which pg_config`
Solved!
I found some lack of library for PostgreSQL on the system.
Only two steps solved it:
brew install postgresql
Then run
gem install pg
For those who are not interested to use brew.
Download PostgreSQL application.
Follow the macOS default instruction to install it.
It is advisable to run PostgreSQl.
Run gem install pg -- --with-pg-config=/path/to/postgress/in/your/applications/folder/`
For example, in my machine it is
/Applications/Postgres.app/Contents/Versions/12/bin/pg_config
i got same problem and i solved
gem update --system 3.0.6
I just switched from Heroku to Amazon Web Services. Previously I ran all of my Rails command line commands using my Command Prompt with Ruby (from my Windows PC). However, after I logged into my Amazon Linux EC2 instance, and then went into the directory of my app I receive this error:
/usr/bin/rails:9:in `require': no such file to load -- rubygems (LoadError)
from /usr/bin/rails:9
when I try to run any commands like rails console.
I reviewed this question, but it doesn't seem like multiple Ruby libraries apply to me because
which -a ruby
only yields one location:
/usr/bin/ruby
Also, this question didn't seem to help as I haven't. When I tried typing in
rvm use 1.9.3
I receive this message:
-bash: rvm: command not found
It's my first time seeing a Linux environment, so any help would be appreciated. Thank you!
I was running into he same issue with the identical error message. From my EC2 instance, I noticed my ruby version was 1.8 (ruby -v). I rebooted the EC2 instance, and this caused Elastic Beanstalk to spin up a new EC2 instance and terminate the old one. The new instance was running 1.9.3, and I became unblocked. I hate magical solutions, but with the old instance terminated, there was no more triage I could do. Hope this helps.
-bash: rvm: command not found
This clearly says that rvm is not installed on your machine or if installed you haven't set the path properly.
Check path
Sometimes there is gem versioning pointing to the wrong one.
This happened with me sometime back----
Disregard! sudo bundle install was bundling 2.3.8 instead of 3.0.0.beta3. Fixed it by specifying the version in my Gemfile.
To make sure the compilation goes smoothly, scroll back in your terminal session and look at the list of prerequisite packages that should be installed (it’s probably best to cut and paste the whole lot of names to save yourself from typing errors).
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion
Now you can use use rvm to download, compile, and install Ruby.
1 rvm install 1.9.3
2 rvm use 1.9.3 --default
Guess it's more of a problem related to RVM and some weird linkage to osx's system ruby? (I installed RVM on a user level)
I have used gem install bundler.
Then run rvm install works fine
I'm having an issue installing the memcached ruby gem on my Mac Pro machine with OS X Snow Leopard (10.6.4).
Memcache is installed and working fine and for most projects I use the memcache-client gem without issue, but this current project I need to use the memcached gem instead.
Installing the gem with env ARCHFLAGS='-arch x86_64' gem install memcached or just via the normal gem install memcached both give the same error when trying to run the application:
(in /src/mojotech/projectr)
dlopen(/Users/cpjolicoeur/.rvm/gems/ruby-1.8.7-p174/gems/memcached-0.19.7/lib/rlibmemcached.bundle, 9): no suitable image found.
Did find: /Users/cpjolicoeur/.rvm/gems/ruby-1.8.7-p174/gems/memcached-0.19.7/lib/rlibmemcached.bundle: mach-o, but wrong architecture - /Users/cpjolicoeur/.rvm/gems/ruby-1.8.7-p174/gems/memcached-0.19.7/lib/rlibmemcached.bundle
However, running file on the rlibmemcached.bundle gives the correct arch?
cpjolicoeur#~/.rvm/gems/ruby-1.8.7-p174/gems/memcached-0.19.7/lib $ file rlibmemcached.bundle
rlibmemcached.bundle: Mach-O 64-bit bundle x86_64
I'm not sure what the problem is, or how to properly install the memcached gem for my system.
I was seeing the same exact error message on Snow Leopard, Ruby 1.9.1, and the memcached gem. I scoured the net for hours for an answer. Everyone suggested this solution, which did not change the error message:
# Did Not Work
sudo gem uninstall
sudo env ARCHFLAGS='-arch x86_64' gem install memcached
I also tried doing 'rake clean' and re-running extconf.rb on the gem. Same error.
Finally, I went through every past version of the memcached gem until I found one that worked with my system.
# This Worked!
sudo gem uninstall memcached
sudo gem install --version 0.17.1 memcached --no-ri --no-rdoc
Version 0.17.1 of the gem is the only version that works for me. I'm an iPhone developer, so have the latest version of XCode installed, and this might explain why my system is different.
This is a late answer, but hopefully useful for someone who runs across the same issue. (With Ruby 1.9.2 on Snow Leopard.)
Install the Perl modules Pod::Simple, Pod::Man, Pod::Checker (via cpan is easiest).
Download the latest version of libmemcached from http://download.tangent.org/ (was libmemcached-0.44.tar.gz as of this post)
Do the configure/make/install dance by hand in Terminal:
tar -xzvf libmemcached-0.44.tar.gz
cd libmemcached-0.44
./configure
make
sudo make install
After this, sudo gem install memcached worked, and the Rails 3 app in question ran fine.
I tried to install the new beta on my system with the command:
sudo gem install rails --pre
but no matter what I tried, I still get this damn error:
Successfully installed
rails-3.0.0.beta3 1 gem
installed Installing ri
documentation for
rails-3.0.0.beta3... File not
found: lib
Since I'm very new to ruby, I really don't know what to do.
How can I finish installing this?
Is this installed already?
Why does it abort here?
All you need to run is gem install rdoc, follow its instructions, then run the install rails command again and you're good. The problem is due to rdoc failing to install when installed with rails, if installed manually it works fine.
Source: http://gist.github.com/565967
^ I had the same problem, and this worked for me.
If you're looking to do ruby/rails development on Mac, I'd strongly recommend not using the version of ruby/rubygems shipped with your mac. What I do recommend is:
Installing homebrew and using that to manage software packages on your mac.
Install brewbygems, which makes homebrew play nice with rubygems: gem install brewbygems
Install rvm and learn to love the different versions of ruby and rvm's gemsets feature: gem install rvm
Once you've done that you'll have a pretty robust development environment and you should be able to install any version of rails without a problem. Just keep in mind rails 3 works best using ruby 1.9.2 (install with rvm by running rvm install ruby-head) and is still in beta, meaning it isn't terribly stable and should not be used for anything production grade (yet).
I found the same error message, while after some google I've successfully installed it by manually 'sudo mkdir lib' in the .../gems/rails-3.0.0.beta3. Though it hasn't raised further problem, I hope someone could tell what should be in the missing lib directory.
You don't really need to do this sudo gem install rails --pre, simply sudo gem install rails. Rails3 is the default package now and out of beta.
It should work fine.
Might be a different solution on your OS, but I got the same exact error in Ubuntu and creating a ¨lib¨ folder under the rails gem folder solved my problem. I have explained the solution in the following post:
Installing Rails: "File not found: lib"
For convenience I will copy it here as well. The solution:
mkdir /lib/ruby/gems/1.8/gems/rails-{whatever your version is}/lib
Explanation: The ¨[sudo] gem install rails¨ command expects the /lib folder (at the end) but for some reason it hasn´t been created yet.
The original source of this solution was the following URL. Hope it helps!
http://www.spritle.com/blogs/?p=915
Same problem with beta 4.
The workaround is sudo gem install rails --pre --no-ri --no-rdoc though I don't know why.
I'm try to install the SQLite gem on a Fedora 9 Linux box with Ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here's the command I'm running and its results:
sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb install sqlite3-ruby
can't find header files for ruby.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
gem_make.out just repeats what was already sent to the console. How can I install this gem?
The SQLite RubyGem isn't actually a RubyGem, it's a "CGem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it and in order to do that it needs the C header files for the Ruby interpreter.
If you compile Ruby yourself, those header files will be installed automatically, however, in RedHat-ish systems, such header files are usually packaged in a seperate package, called <whatever>-dev. So, in this case you will need to install the ruby-dev package and possibly the libsqlite3-dev (Ubuntu) or sqlite-devel (Fedora) package as well.
However, you might be better off just installing your Operating System's pre-packaged libsqlite3-ruby package, that way all the dependencies are automatically satisfied.
(Note: all package names pulled out of thin air, might be different on your system.)
You probably need the ruby dev package. For Ubuntu you have to install ruby1.8-dev which includes the ruby header files. A quick google says that the yum package is ruby-devel. so run this:
sudo yum install ruby-devel
I faced problem installing sqlite3-ruby gem on my fedora 13 box.
It was fixed after sudo yum install sqlite-devel
When I had that problem:
gem install sqlite3 -v '1.3.9'
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
For me worked, installing the "libsqlite3-dev" with:
apt-get install libsqlite3-dev
sudo apt-get install ruby-dev
Fixed it for me.
On Ubuntu 9 and 10 try:
sudo apt-get install ruby-dev
sudo apt-get install sqlite3-dev
Then run
gem install sqlite3
Run the following for Fedora OS:
yum install rubygem-sqlite3
On alpine, you need to install the sqlite-dev package.
I also faced this same issue, the problem is that your Linux installation requires the development libraries for SQLite3 to be installed in order to build the gem.
Here's how I fixed the issue
Open your terminal and run the following commands
sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev
And then try installing Sqlite3 gem again using this command
gem install sqlite3
That's all.
I hope this helps
Do you have all the source code required to build sqlite3-ruby? Gem is trying to compile some C code and cannot find the headers. You can probably use a fedora rpm for sqlite3-ruby (I don't use fedora, but I'm sure one exists) if you prefer to forgo compiling. Personally for ruby stuff, I prefer to use gem rather than a distro's packaging system.
I'm not really familiar with Fedora, but in Ubuntu when you are installing packages you have apt-get, and you have to install the build-essentials which includes gcc and other compilation tools for C. I would say that could be your issue, and you make look into how that can be install either using RPM or apt-get on Fedora.
I fixed the problem on my OLPC (Fedora 9) by installing 'gcc' oddly enough. It seems like it should have been one of those dev packages, but no.
Also, regarding the other packages, the suffix is "-devel", not "-dev", so make sure you get those ending right: "ruby-devel", "sqlite-devel"...
Once you get that installed, if you get errors about your gems being too old "< 1.3.1" when you try to run various rails scripts, eg: script/server or script/console, google "upgrade_rubygems" to fix that problem...
HTH...
Run "sudo yum install sqlite-devel" and then "gem install sqlite3". Had the same problem on my Fedora 15.
I had this same exact issue...instead of gem'ing the missing pieces I used synaptic on unbuntu.
The key package for me was libsqlite-ruby1.9.1 ... I documented my experience (for reference) with this error at :
Sqlite3-gem-error-during-bundle-install
I encountered this error while running bundle install after generating a react-rails app on Fedora 29. I was able to identify a suitable development package by running dnf search sqlite3, then installed it dnf install libsqlite3x-devel. This fixed it for me.