"could not locate gemfile" when doing bundle install on existing rails project - ruby-on-rails

I've been given an existing rails project that I am trying to play around with. however, when I try to run bundle install or rake db:migrate, I run into problems so essentially, i can't really do anything with the code I've been given.
The biggest problem as I see it right now is the fact that it can't locate my gemfile when I bundle install?
How can I find my gemfile.. is there supposed to be one in the root folder of the application?
Is there another step I need to take to initialize an existing project that someone has just copied and pasted to me? Thanks!

Yes, you should have a Gemfile in the root directory of your app.
If you are developing in a Rails 2 app, you might want to check out the Bundler.io page about Rails 2.3:
http://bundler.io/v1.7/rails23.html
If you are using Rails 3+ you can take a learn from Bundler's page on Rails 3 use:
http://bundler.io/v1.7/rails3.html
If you just need to get started with a Gemfile, go to a different directory and generate a dummy app:
$ rails new temporary-app
Copy over the Gemfile to your directory. It will only have the default gems listed, but you may be able to "discover" your needed gems as you go. If you happen to have a Gemfile.lock file then you can see the gems that you need at the top of the dependency tree.

Related

Adding ruby on rails to an existing react native app

Background
I'm developing a React Native app for the first time. I've gotten to the point where I need to start working on the back end and I'm going to use Ruby on Rails to do that. I've installed Ruby and SQLite3, and I've successfully added Ruby to my project.
Problem
As of right now, when I try to install bcrypt and jwt to the Gemfile in the project, I ran gem install bcrypt/jwt and that seemed to work, but when I try to run bundle i get an error: "Could not locate Gemfile". I am certain the Gemfile is in the directory I'm running the commands in, as I can see it in VS Code and also going down the path in C:/, etc.
Question
Can I actually add Ruby on Rails to an existing project? What could be the cause of this issue?
Thanks a lot!
If you have created a new Rails-App via rails new myapp you can cd into this directory and call bundle install.
rails new myApp && cd myApp && bund
Please check that you are in the correct directory. If you are sure that you are in the right directory then check your current rails version with rails --version.
Make sure you are in the project directory before running bundle install. For example, after running rails new myproject, you will want to cd myproject before running bundle install.
gem install - like npm install -g, programm to fetch gems,
bundle is fetching list of gems from Gemfile in your app(current folder), like package.json (not sure about naming)
1. Can I actually add Ruby on Rails to an existing project?
Yes, sure. You have a lot of variation to do that
here link the good article how create rails-react app, then you can move your front end part to react folder in the new rails application.
you can create new rails as separated application, in folder what you want as API with option rails new your_app_name --api, then send requests from react app directly to rails app port or IP(it is harder to implement, but I think it is right solution).
2. What could be the cause of this issue?
it is possible because you do not have rails app do not exist
you do not have Gemfile in your folder.

Ruby on Rails - ran "gem update," printed lots of text, but no gems actually updated?

I ran gem update the other day in Command Prompt with Ruby and Rails. There was a flurry of text, and it said such things as ...rdocs rails 4.0.0 (I forget exactly what it was saying) and all in all it took about 40 minutes (the rails 4.0.0 listings seemed to be longest.) However, I used bundle install after that, and I'm still using 3.3.2 rails, and worse, using old models of all the other gems (most noticeably shoulda and shoulda-matchers.) Please help me see what I did wrong, whatever it might have been. I'd like to update my gems all at once, if appropriate (I am new so I don't know if its recommended.)
If you want to update your project gems (which features updating Gemfile.lock and actually updating proper gems), you need to run:
bundle update
To run an RoR command line on a project, you have to make sure you are in that project's root folder beforehand. For example, if your projects are in c:\projects and you are working on project trythisone, you need to be in c:\projects\trythisone before you run bundle update or any similar command.
You probably don't need rdoc, anyway, so follow this advice. To be clear, in Windows 8 you would need to go to your users folder and add a file called ".gemrc". Thus, for a user called "myuser", you would have a file at: (Earlier Windows versions would be in their particular users folder)
c:\users\myuser\.gemrc
This file would contain the following text:
gem: --no-ri --no-rdoc
Marek Lipka was correct in that bundle update is needed.

RVM why don't gems install to locally to project folder?

So here's my problem:
I have a project and I am trying to install Gems locally to that project. For example if I install devise from the Gemfile and then run a bundle install it won't put any of the controllers in the controllers directory of the project. Instead I have to hunt through the RVM directories to get that particular gem's controllers, copy them to my project and then start writing my project from there.
Any suggestions?
I think the comment above answered your question - when you add a gem like Devise to your app, it doesn't generally drop code directly into your application. Sometimes it provides a generator which will install some parts of it, but mostly it alters config files so that the code in the gem gets pulled into your app when it starts.
You can ask bundler to install gems in the "vendor" subdirectory of your app, instead of in the main RVM/Ruby location, with the --path option. But you usually only want to do that for production deployment, not development.

Files added to my Ruby Project when using RBENV

After installing RBEnv and rebuilding my ROR project, I now seem to have added many, many files to my project. They are in /vendor/local, and appear to duplicate what you would normally find in /Library/Ruby/Gems.
My project will not run without these files present (I get the message Could not find rake-0.9.2.2 in any of the sources.
I had difficulties with my RBEnv installation. I have what I suspect are other issues (like I have to bundle exec rails instead of just running rails). I suspect that I have done something wrong and should not have these files in my project. What I'd like to know is:
1) Should these files be there?
2) How best to fix this (if this is not how it is supposed to work)?
3) If the best approach is to start over and reinstall rbenv, how do I clear it all out?
It is true that using RBENV will end up putting copies of your gems in the project's /vendor/local folder. This is to remove any dependencies on your base gem set. These files need not be part of your source repository, as long as your 'gemfile' and your '.rbenv-version' file are included in the repository.
Another price you pay for using rbenv is that you must bundle exec rails <command> and bundle exec rake <command> from here on in.

How do I download and run a rails app?

As an example, I want to download: https://github.com/banker/newsmonger and tinker with it (to learn Rails). I've downloaded the zip and when I go into that folder and type rails server, the terminal window says to create a new rails app
This is a Rails 2 application, and so as ennuikiller said, you'll need to run script/server.
You may run into problems with dependencies not being installed in this application, which is a problem that normally (now) would be solved with Bundler. Due to this being a Rails 2 application, it doesn't support Bundler out of the box and the owner of the repo hasn't updated it to support that, and so you're dead outta luck there.
What you'll need to do is attempt to run rake gems:install (which may or may not work, depending on the sun's positioning) which will install the gems specified in config/environment.rb and the proper config/environments files using the config.gem methodology. This was how it was done in Rails 2, and caused so many problems that Bundler was created.
If that doesn't work, contact that banker guy on GitHub and ask him what the deps are or work out the dependencies yourself.
Good luck!
Depending on the version of rails this app uses you may have to execute the following :
script/server

Resources