Error after bundle install on production - ruby-on-rails

Every time i install a gem on production using bundle install i got this error
Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
Also i get the following warning when i do a bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
I tried removing the Gemfile.lock and re-installed the gems but it still not working
Thanks in advance.

Related

Cannot run "rails server" because of failure to install 'pg' in gem

I am new to ruby on rails and I just downloaded a new Rails project directory that my friend sent to me. I put that directory on the Desktop and cd into it. I want to play with the code on my local host to learn from the code. But when I tried to run "rails s", it gives me the error saying that
"Could not find pg-0.17.1 in any of the sources
Run `bundle install` to install missing gems."
So I ran "bundle install", then it gave the error that
"An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling."
I googled the problem for a while but I did not find any solution..
"rails s" stills works fine in my own project's directory. But how can I make it work in the directory I just downloaded? Am I supposed to do some other setup or installing?
Make sure you have installed postgres on your local machine.
gem install pg --with-pg-config works, bundle fails
Here how I made development environment on my Mac.
Install PostgreSQL via Homebrew package manager brew install postgresql. This should install all necessary header files for gem compilation.

Why is "install" run twice?

I'm going through Micharl Hartl's well known Rails tutorial, and this piece is confusing me. Every time a new app is set up, these commands are run:
$ bundle install --without production
$ bundle update
$ bundle install
I don't really get why install is being run twice. What is the effect of these three commands run in this sequence?
You should not have to run bundle install twice as bundle update will also install all of your gems (as well as updating them to their most current version). I have not read the tutorial you mentioned but perhaps the purpose of the second install is to install all of the gems, including those reserved for production.
Your second question, what is the effect of these three commands:
bundle install --without production
Inspect the gemfile, ignoring gems that are reserved for production
Resolve all dependencies
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle update
Inspect the gemfile
Resolve all dependencies from scratch using the newest version of each gem and completely ignoring Gemfile.lock
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
bundle install
Because this is the first run of the production gems, inspect the gemfile and resolve dependencies of the production gems
Use Gemfile.lock for exact versions of all other gems to be installed
Install all gems and dependent gems
Save the exact version of each gem to Gemfile.lock
Hoped this helped, for more detailed info about the two commands check out this and this.
$ bundle install --without production prevents bundler from installing any of the production gems. It also gets saved in your local repository and you don't have to run it more than once. Any subsequent run of bundle install will include --without production.
bundle install installs only the missing gems from your Gemfile, while bundle update updates/installs every single gem to the latest version as specified in the GemFile..

ROR bundle install : git://github.com/Goin/dm-migrations.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)

I have an existing ROR application I've inherited. I needed to add a GEM file to the Gemfiles list. I then ran a "bundle install". Apache (/phusion/rack) now shows the error "git://github.com/Goin/dm-migrations.git (at master) is not checked out. Please run bundle install (Bundler::GitError)". According to bundle this gem is installed however: "/usr/local/lib/ruby/gems/1.8/bundler/gems/dm-migrations-3d190029bb8c".
What is the root cause of the problem and the fix?
TY,
Fred

I'm having trouble running my Rails web server

I have installed ruby193 and I've installed rails via the command prompt (I also installed a DevKit). However, whenever I try the command:
rails server
I get this error:
←[31mCould not find gem 'jquery-rails (>= 0) x86-mingw32' in the gems available
on this machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
I've tried a bundle install and it gives me an error with when trying to install the json gem. Any suggestions?
make sure in your Gemfile you are including the right gem (no misspellings, etc)
Looks like you are on Windows.
I defeated the very same problem on Windows by manually installing my gems from Gemfile (gem install gem_to_install). After successfully installing a particular gem I ran bundle check to see what else I need to install. And this way after few installed gems I ran bundle check again and saw the output The Gemfile's dependencies are satisfied.
And then server started. I wish you the same!
P.S. You can install few gems at once: gem install gem1 gem2.

rails - Unexpected behaviour of 'bundle install': installation into a folder in the app directory

I've started a simple rails application. I tried to install Compass and Haml, (using gem install) and ran 'bundle install'. The bundler re-installed all the gems and placed them in a new folder '/haml' inside the main directory of the rails application.
Your bundle is complete! It was installed into ./haml
Is that expected? Shouldn't these gems be placed in the rvm directory, not in the application directory?
$ bundle install --system
Will solve your problem.
Gems will be installed to your default system location for gems. If your system gems are stored in a root-owned location (such as in Mac OSX), bundle will ask for your root password to install them there.
While installing gems, Bundler will check vendor/cache and then your system's gems. If a gem isn't cached or installed, Bundler will try to install it from the sources you have declared in your Gemfile.
The --system option is the default. Pass it to switch back after using the --path option as described below.

Resources