Ruby on rails new app is not creating - ruby-on-rails

I started to develop the new RoR web app and faced weird issue.
I wanted to create new app with Postgresql. So I installed the Postgres with brew and MacOS desktop app. And type rails new test-app --database=postgresql.
At this moment, I can't install bundles because there is certain
error.
An error occurred while installing pg (1.0.0), and Bundler cannot
continue.
Make sure that `gem install pg -v '1.0.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg
run bundle exec spring binstub --all
Could not find gem 'pg (< 2.0, >= 0.18)' in any of the gem sources
listed in your Gemfile.
Run `bundle install` to install missing gems.
So I can't start new app.
Is this an issue that is occurring because of the mismatch between ruby and postgres version?
And how can I create new app with postgres?
I am currently using Mac OS high Sierra, postgres 10.5, rails 5.2.1

Try to skip running Bundler: rails new test-app --database=postgresql --skip-bundle
Once you've generated your app, you'll still have to troubleshoot why pg ins't installing. The PG gem should install just fine as long as the database is there and your system can build the gem's native extensions, so my first guess is either Postgres isn't installed or it can't be found in your environment.
Either way, this does answer your question. Skip the bundle and voila - Rails will generate a new clean app for you.

I've posted some comments, but i already seen that it seems to be an error when installing postgresql via brew. It's not common, but it happens sometimes.
Here's a quick fix:
brew install libpqxx
Make sure to run also
brew update
and restart your PostgreSQL server via:
brew services restart postgresql
Also make sure to clean up brew:
brew cleanup
If the error is still there, post your Gemfile and your database.yml file as well.
Greetings!

Related

trouble installing postgresql for rails app

So I would like to deploy my rails app on heroku right? Wanna switch from sql3 to postgresql. Should be simple but I keep getting an error when trying to bundle with gem 'pg' in my gemfile. I used homebrew to install postgresql with all its native extensions before trying to bundle. Any ideas? I am on Mac OSX high sierra.
An error occurred while installing pg (1.1.3), and Bundler cannot
continue.
Make sure that gem install pg -v '1.1.3' --source 'https://rubygems.org/'
succeeds before bundling.
That's all I get for the error. Not helpful. I went ahead and uninstalled postrgresql that I installed locally to my machine from their website as well as with homebew. Gonna start from scratch. I haven't done this in years so any help would be appreciated!
I've run into this before where you attempt to install the PG gem, but postgres is not yet installed. Even if you install postgres after that, you'll still run into troubles (this has to do with required libraries not being available or not found). I would recommend uninstalling both, then installing Postgres first, then the PG gem. This is a common gotcha, unfortunately: Installing PG gem on OS X - failure to build native extension Also, I would recommend https://postgresapp.com/ if you continue to have trouble installing PG or having the gem not see your install properly.
After tons of research and trying everything, found an older question on stackoverflow from 2014. If you install postgresql with homebrew like I did, running the command ARCHFLAGS="-arch x86_64" gem install pg will install the gem if bundling or gem install pg don't work. Hope that helps other people who might be stuck like I was

Rails installation on hostmonster bundle install fails

So I had a rails app up and working on my hostmonster account just fine. I then updated a few things in my dev environment / pushed them up to github / pulled them back down on my production environment. Now its giving me the error Could not find pg-0.17.1 in any of the sources (Bundler::GemNotFound).
This is a new gem i installed in my dev because i was attempting to move to postgresql for dev and live....for now im using postgresql in dev and mysql2 in production. I know this isn't optimal but im working on it.
I tried running bundle install to get the pg gem installed and it fails with the error
Gem::Exception: Cannot load gem at [/usr/lib64/ruby/gems/1.9.3/cache/rake-10.2.2.gem] in /home4/muscorei/workspace/vollapp
An error occurred while installing rake (10.2.2), and Bundler cannot continue.
Make sure that gem install rake -v '10.2.2' succeeds before bundling.
I try installing rake and it works fine...try again..same error. I have found one question on here that seems to fix this for others but it requires running of gem update --system which you cannot do for hostmonster. Any ideas?
So here is another "related" issue. When i type in gem list --local I see that rails is installed at version 4.1.0....however when i do rails -v it shows the systemwide version of 3.2.13. I don't EVER have any of these annoying issues on my dev environment.

no metadata found in activereocrd-3.2.9.gem when running bundle install in a rails 3.2.9

am a newbie in rails. working on Windows 7, 64 bits. Installed my environment through RailsInstaller. latest version ofcourse.
When creating a new project, (keeping the gem file as default) and having the bundle install run, am getting the error
gem::package::FormatError: no metadata found in
D:/RailsInstaller/Ruby1.9.3/bin/cashe/activereocrd-3.2.9.gem
and error occurrend while installing activerecord (3.2.9), and bubndler cannot continue.
Make sure that gem install activerecord -v '3.2.9' succeeds before building.
I tried to run the gem install activerecord..as instructed still bundle install does not work and i cannot run the rails server. (rails s)
When changing the rails version in the app gem file to 3.2.8 instead of 3.2.9 everything seems to work and the rails server runs succefully. What is wrong?
I uninstalled railsinstaller and all other leftover folders.
reinstalled railsinstaller. Problem solved.

Why it's so slow to use `rails new`?

The version is:
bash-3.2$ rails -v
Rails 3.2.9
And my ruby is the built-in ruby on MacOSX:
bash-3.2$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
bash-3.2$ which ruby
/usr/bin/ruby
My problem is that in the last step of rails new ( run bundle install), it seems that rails need to connect the internet to download some packages. And usually I need 5 minutes just wait for rails to create any project using rails new.
I was wondering whether somethings is not configured well for rails on my computer.
Another strange thing is that after I finished rails new PROJECT_NAME, it shows:
Using sqlite3 (1.3.6)
Using uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
It seems that sqlite3 has already been installed, however, when I try:
bash-3.2$ bundle show sqlite3
Could not locate Gemfile
It still complains that sqlite3is not installed. Maybe that's the reason that rails new is slow (Even sqlite3 has been installed once. It still needs to download the bundle)
Before bundle install, rails asks for my system password:
Enter your password to install the bundled RubyGems to your system
But I'm still not sure whether these packages have been installed into system, as bundle show sqlite3 failed.
Does anyone have ideas about why rails new is so slow on my computer? Thanks!
Another solution is to use RVM. It is similar to rbenv. I personally use RVM. I don't and would not recommend using the gemsets. Bundler does the separation of gem versions anyway.
Check what is up with your bundle install i.e. the last step in the rails new sequence. Run this instead:
rails new appname -B
The -B flag tells rails to "skip bundle" (reference). Then go into the app folder to run:
bundle install --verbose
Check for potential errors in the output.
Using different bundler versions can give you different results. So try other versions.
gem uninstall bundler -v your-version-number
gem install bundler -v new-version-number
In 2016, we got bundler v1.12.x which is causing some users to experience slow bundle install issues. In this case, using 1.11.2 is the faster option until they fix it.

Ruby on Rail error installing SQLite, permissions problems

I've installed Ruby 1.8.7 and Rails 3.1.1 on my Mac OS X Leopard. However I wasn't able to install the SQLite gem. I've seen plenty solutions here, but none of the workout for me. Every time I tried to bundle my app I get this error when it comes to the SQLite gem:
Errno::EACCES: Permission denied -/Users/eduardoribeiro/sites/models/vendor/bundle/ruby/1.8/gems/sqlite3-1.3.4/API_CHANGES.rdoc
An error occured while installing sqlite3 (1.3.4), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.4'` succeeds before bundling.
I'm running
$ sudo bundle install
It seems that the compiler it's trying to install the sqlite dependecies inside of the folder of my app. I had the PATH correctly defined and even created a .bash_profile in the root of Mac OS X.
Any ideas?
Have you tried running gem install sqlite3 -v '1.3.4' at all before running bundle install ?
That could be your problem, if not try sudo gem install sqlite3 -v '1.3.4' then bundle install again.

Resources